It's called co-evolution. The orchids don't 'know', the ones who, by accident, best fit the shape of insects manage to spread more of their pollen. And there's always a certain distance, or a ability of insect sight, that allows it to be fooled. It doesn't have to start from perfect mimicry!
Here some videos explaining the concept further:
http://www.youtube.com/watch?v=JW1rVGgFzWU
http://www.youtube.com/watch?v=XHGIJIc1rag

