Yes and no. They can track play time when you launch a game through the Steam client, and they can use DRM to enforce launching games through the Steam client. If you launch one of the few DRM-Free Steam games without using Steam, your play time won’t increase.
GOG also tracks play time if you launch a game via GOG Galaxy. The difference is, every single-player game in their catalog can also be played without GOG Galaxy (and indeed, this is explicitly why I buy games from GOG—I don’t like clients, I just want an executable).
From my (admittedly limited) experience with GOG games and Galaxy, only games downloaded via the GOG website (with 'offline backup game installers') can be launched without Galaxy; games installed with Galaxy will force Galaxy to be running alongside it
Steam is DRM
A lot of people definitely treat Steam's refund system this way, and Steam's automated refund process seems built to encourage it. You could also make a strong case that this is better for everyone, since consumers are more likely to take a chance on a game they're not sure about. On the other hand, it's a problem for games that are designed to be less than two hours—and it does basically require a DRM implementation.