Usually it's not calculated at all. It's just bad to take pawns and give your opponent a huge lead in development. Sometimes there are dozen of variations that all work out, but there's no way to check them all during a game.
If they calculate something long and difficult though, then they're a really good player!
Analysis and experience help a lot. You play various gambit type positions enough and you'll have a feel for when there's compensation.
I am used to watching youtuber Matojelic's chess videos on famous novelties but sometimes there's a postion where a pawn looks free(I'm not talking about traps or cheapos) but if you take it there would be a very long variation so long that It would be difficult for me to be able to calculate that far ahead whether it be live chess.com 30 0 chess or OTB chess.
How does someone calculate that far ahead exactly(when a variation doesn't look like it's winning until the very end of the long variation)?