Yes, the male flower of a courgette has just a short thin stalk, but the female flower has a mini courgette behind the flower - in other words, the female flower turns into the courgette, the male flower just does the pollinating. Squashes and pumpkins are the same and none will produce fruit without pollination. Each plant produces both male and female flowers but you are more likely to get good fertilisation with several plants as there is more chance of there being both male and female fowers out at the same time with several to choose from. As well as using a paintbrush to aid pollination, you can pick a male flower, remove its petals and rub the pollen directly into the female flower.
Cucumbers are different in that there are modern all female varieties which don't require pollination and in fact the fruit of these becomes bitter if pollinated. Occasionally these do produce male flowers which have to be removed before they open (mine did that this year). Old fashioned and outdoor cucumbers have male and female flowers which I think are left to pollinate themselves but I have never grown them so I don't know for sure. The female cucumber flower has the tiniest ever cucumber behind it, which quickly grows.
Yep - you can't get away from sex, even in the veggie garden