I'm very new with bikes, I just got my new bike since I was a kid like 25 years ago, I bought a Trek Marlin 7 2020 which comes with a 2 chainring crankset and 9 rear gears. I've been hearing that is not good to use the small chainring with the smaller rear sprockets and neither the opposite the biggest chainring with the biggest sprockets but some people says that with a 2 crankset it's safe to use all gears with any of the sprockets, so I'm very confused... In your experience what would be your advice? Thanks a lot!
This is "older" advise that used to be gospel but these days has been engineered to be less of an issue.
The chainrings and cassettes are constructed in opposite directions. That is the big chainring is on the outside, and the big cog in the rear cassette is on the inside nearest the midline of the bike.
Upshot, when your chain is on "big-big" meaning the biggest chainring and the biggest cog, your chain will be doing a zig-zag, with bends where it leaves the cog and where it arrives at the chainring. Same goes for the "small-small" combo.
Realistically, this is far less of an issue than it used to be with better engineering. Your chain may wear if you crosschain occasionally, slightly faster, but not measurably so.
Given that your bike is new, its engineering will be of modern standards and not that of 80s bike transmissions.
If you're grinding up a hill, you should be in the smaller chainring. If you're on the flat you should be in the bigger chainring. But a few seconds in big-big when pulling away from a red light won't upset anything.