Carbon MTB would lean towards new, out of fear of hidden frame cracks/crash-damage. Ally, I guess it depends on how well maintained you think the bike has been, as it's arguably easier to inspect the welds for cracks... if it's 2nd hand from a shop, then possible, i guess, but 2nd hand from a random on eBay, personally, probably not unless it had a load of receipts for upkeep.
I like to think I look after my bikes, cleaning them after each ride, lubing, occasionally stripping down bits to re-grease, but there's still wear and tear. Are there receipts for the past owner taking it to a shop to service? If they're doing it themselves, then what evidence/receipts are there for replaced components BB, headset bearings, fork service parts, etc.
Just thinking that I don't get out on the bike half as much as I'd like, but I've still gone through a couple BBs and the odd bearing in the last couple years, not to mention brake pads and a few tyres... And, on my previous 2x10 bike I damaged the rear derraileur so swapped it over to a 1x11 setup. This is all part of MTB ownership/upkeep - so I'd want to see proof of that when buying a decent 2nd hand bike, that I'm effectively putting my life/health in when chucking myself down a rocky steep descent.
Otherwise, factor in the cost of a decent service, some new parts (probably a BB) ontop of the 2nd hand price... e.g. a local bike shop charges about £100 for full bike strip down, service and rebuild. Plus £35 for fork service and £15 for shock service, plus parts... So, probably factor in £200 ontop of the used price for peace of mind, if there's no proof of recent service?
Saying this... I guess it depends on what riding you're wanting to do. If it's a mtb for cruising canal paths, the odd ride on a bridleway or trail center blues, then I'd probably be more ok with 2nd hand. If you know you're going to be leaving the ground with drop-offs or jumps, then probably new...
Could always try somewhere like paulscycles that tend to offer past seasons bikes for a decent discount? Or leisurelakes, Evans, etc. with a 0% finance?