I mountain bike every chance I get (1500 miles this year), including a little fat tire biking in the snow. But in the Winter I train on my stationary bike in the basement to help keep up cardio fitness, especially for climbing.
Even though I use a couple YouTube videos that simulate climbing to get my heart rate up and work my legs, it's not near as good a workout as the MTB for these reasons: 1. It's more fun to be outside; 45 minutes on a stationary bike is a commitment while outdoors I ride 1.5 to 2.5 hours; 2. Grinding uphill on uneven ground is harder work; 3. Going up and down both requires muscles to maintain balance and stability that won't get worked on a trainer; 4. Especially going downhill, you need some upper body fitness to help absorb the terrain: and 5. There's a mental workout in the attention needed to navigate terrain, especially going downhill when you have to make constant quick decisions.
I don't road bike but I imagine the trainer is more like riding a flat road. BTW I'm 62 years old.