This behavior was introduced in 26.1-snapshot-3.
The bug
Melon and pumpkin stems used to be able to generate their fruit on one of the adjacent blocks if it was either a grass block, moss block, pale moss block, dirt, coarse dirt, rooted dirt, podzol, mycelium, mud, muddy mangrove roots, or farmland. As of a recent version, they are only able to generate their fruit on farmland.
Fix: https://www.youtube.com/watch?v=BlDIXBLiVJA