When I wear my Advanced Master Gardener hat, this is a top question. Gardeners wonder why they see flowers on squash, cucumber and pumpkin plants, but they don't see any fruit growing.
It's the difference between the boys and the girls.
These plants have male flowers and female flowers. Here's how to tell the difference. The female blossoms already have a tiny fruit on them when they bloom. The males don't.
A tiny cucumber looks kind of like it should be a male flower because of its phallic shape, but it isn't. It's a girl!
The fruit is an ovary. Bees or the wind carry pollen from the male flowers to the female flowers. Some serious gardeners hand pollinate their plants. The eggs inside that tiny fruit, the seeds, are fertilized and just like that. Seeds are ready for next year.
If the flower at the end of the tiny fruit is not visited by pollinators, the little fruit will shrivel and die.