I can't tell if those are diagrams of what the circuit should look like, or actual in-game implementations.
One of the best things about dwarf fortress is that playing it using that initially-confusing interface rather than shiny graphics is like doing math using symbols and equations rather than paragraphs and paragraphs of words.
A
→o * o→M O
o * o
B
The mechanical power goes in the first →, and the [M O] part is the output. A and B are the AND inputs. Gearboxes actually look like *, but o is also being used for gearboxes, albeit gearboxes that are just there to drain power.