Sometimes I know what form I want to write a poem in. Sometimes there's a bit of trial and error and it only gradually becomes clear to me what form the poem should be in. Quite often I will begin a poem in free verse and then realise it could be a sonnet or a villanelle or whatever. Sometimes it will change from one form to another - what will sometimes happen is that I'll start off in quite a short form like a triolet and then I'll realise there's more to say so I'll have to expand it into a longer form. Sometimes I'll try out a form...sometimes I'll write something just as an exercise, as a way of trying to master the form but those aren't usually publishable.