In the life-cycle of an angiosperm plant (a "higher" plant, so not mosses, not pine trees), the flowering comes before fruit production.
When the plant
flowers, pollen (the male gamete, like sperm in animals) from the male parts of the
flower is delivered (by beas, wind, etc.) to the female parts of the
flower, and goes down a tube to the ovary. This is pollination. When the male & female gametes fuse, it's fertilization (think sperm + egg). The result is an embryo. The embryo is contained within a
seed. The fruit is the non-
seed tissue associated the
seed. There are lots of different ways this plays out. Your pear is a simple, fleshy fruit called a pome. The nectarine is a simple freshy fruit called a drupe. Strawberries are aggregate fruits. Tomatoes are simple fleshy fruits called berries! And so on. Classification factors in the type of
flower arrangement, how the ovules of each
flower associate with one another (if they do)... .
Botanically speaking, you can't have a fruit w/o a
flower. (Which brings us to your baby squash problem. These may be fruits that formed without pollination & fertilization, which sometimes happens. But there'd be no mature embryo within the fruit.)