How can dehydrogenation steps in some biochemical pathways produce ATP?
You have to consider the full redox reaction to determine if the reaction is favourable or not. It's not correct to think of enoyl-CoA alone as "higher energy" than acyl-CoA, because of the free energy difference $\Delta G$ of the half-reaction:

acyl-CoA  $\leftrightarrow$  enoyl-CoA + 2 $e^-$

cannot be determined without knowing what the electron acceptor is. You might be thinking of the enoyl group as "higher energy" because it is reactive towards H$_2$ (as in hydrogenation reactions), but that's not the relevant redox couple here.

In this case, we should consider the energetics of the entire process of electron transport, as shown in your diagram. Since the intermediates (FAD, ETF, quinones) all cancel out, the overall reaction without ATP synthesis is:

acyl-CoA + 1/2 O$_2$  $\leftrightarrow$  enoyl-CoA + H$_2$O

This reaction is highly favourable, with a $\Delta G$ of about -150 kJ/mol, because O$_2$ is a very good electron acceptor. (See this site for free energy calculations.) This is more than enough to drive ATP synthesis (about 45 kJ/mol).