There's definitely some trust there, but the drivers have been doing this since they were kids in karts with dad turning the wrenches, through the lower formula series, and into F1.
And the race engineers and mechanics have mostly all done the same, with many of them having studied in college for just these jobs. The UK has quite a few unis and technical schools with motorsports programs for both roles (typically motorsports engineering for the former and certificate programs + apprenticeships for the latter). And they likely started in F3 or elsewhere, then F2, then F1.
Haas runs the "TGR Haas Driver Development Program" to train younger drivers, mechanics, and engineers using historic cars (thanks to the rule change for this season, the 2025 cars qualify). I assume the other teams have analogous programs.