Bismut formulas and applications for stochastic (functional) differential equations driven by fractional Brownian motions