B is just handling everything it gets to A. A must choose where to retrieve data depending on its data. Clearly only A should have the DynamicForward tunnel, the role of B is just an intermediate host for connectivity. Normally B should only require a classic LocalForward to present queries to A.
This could be done in different ways, but the most simple and secure method takes advantage of the ProxyJump feature which will show A as if it was directly reachable, thus not requiring anymore to ponder how B will interact with the intended port forwarding. One can consider B is almost invisible. So in the end, the configuration below can be put in
Invoked with only:
Without configuration file the equivalent command line would be:
ssh -D 1081 -J userb@B usera@A
UPDATE: should ssh's version be older than 7.3 (as it appears to be for OP), ProxyJump can still be replaced by ProxyCommand + ssh -W like this:
as configuration file
ProxyCommand ssh -W %h:%p B
or without configuration file the equivalent command line:
ssh -D 1081 -o 'ProxyCommand ssh -W %h:%p userb@B' usera@A
The SOCKS5 API will be available on the client as
localhost:1081 (unless putting back
0.0.0.0:1081 (or using GatewayPorts/-g) to make it available for other clients). Under the hood, handled by a pair of pipes, a spawned sub ssh process will establish a tunnel through Host B and will present A's ssh server to the initial ssh command: the whole ssh is tunneled that's why there's no specific additional port forwarding to be configured.