The OP asked about tomato and cucumber plants, not fruit trees. And for many gardeners, the point is not instant gratification- there is a happiness and contentment to be gotten from planting something, nurturing it, and watching it grow. The reward is not the fruit, it is the doing of it all. Of course, it's also fantastic when you get your first piece of fruit off of it.
When I lived in Canada, there was an old peach tree in my backyard. It had been neglected for years before I bought the property, not pruned or cared for. It would produce nothing for three years in a row, then have a huge bumper crop of peaches to the point where I had canned 40 jars, frozen 40 bags full, made peach pies and cobblers until me and the kids were thoroughly sick of them and I was begging my friends to take peaches, please. One day I was out on the sidewalk chatting with the 79 year old woman who lived down the block, and who had lived there all her life. I asked her if she wanted to come back and look at my garden. We wandered back there and she got tears in her eyes when she saw the peach tree. She told me she remembered watching the guy who used to live there planting the peach pit that grew into that tree when she was 7 years old.
You can't buy that in the market.