How are the 737’s elevator and aileron cables attached to their control tabs without impeding the control surfaces’ motion under hydraulic power?
The tabs themselves are not locked -- that lock you mention is upstream: an input lock. Next time you sit next to the wing, watch the aileron as the pilots check the controls and notice how the tab moves opposite (alternatively, and rewindable, you can watch it here).
With the input locked, the tabs are free to move without directly feeding back into the actuators/rods/cables (indirectly though, the elevator tabs serve two different functions depending on the flight regime).


Source: b737.org.uk

Above is a photo for the elevator/tab deflection as seen on ground with the elevator up and tab down. And when unpowered, the elevators droop, and the tabs would be trailing edge up as expected, as seen in the following photo:


Source: wikimedia.org

The mechanism
For the elevators, the cables (from the control column) move the aft control quadrant. From there, no more cables -- a rod moves a differential (floating) lever, which is the input to 1) the hydraulic actuator 2) the manual reversion lever (either/or).
With hydraulic power available, locking pistons lock the manual reversion lever (not the tabs). With loss of hydraulic power, the now unlocked manual reversion lever changes the differential lever's pivot point -- switching the input to the aero tabs.
Here's a drawing from Boeing's manual reversion patent. I colored the differential lever yellow and the manual reversion lever red (locking pistons are shown in another figure), and drew the two pivoting axes:


Source: patents.google.com

This is how with the manual reversion lever locked (hydraulics working), elevator movement would move the tabs in the correct non-impeding opposite direction (rod 34 need not translate), e.g. pull back - elevators up - tabs down. This is also illustrated in Fig. 5 in the patent.


Source: gov.uk/aaib-reports

Above are the rods that move one of the tabs on a 737-700. The ailerons are covered by the same patent (same principle).
But that is not all
At low-speed, triggered by the extension of the TE flaps, a hydraulic/spring mechanism shifts the pivot point of the tabs, which in turn reverses the tabs behavior, making the tabs follow the elevators, e.g. pull back - elevators up - tabs up. This increases the camber giving more control.
The relevant Boeing patent is here; it's an earlier design where each elevator had two tabs, as seen on the 707:


Source: publicdomainpictures.net

On the 707 (and KC-135, etc.), the inboard tabs are the convertible type -- their anti-balance mode is to make the pitch control heavier in cruise; the balance mode is used at low-speed (activated by stabilizer position) to counter the increased air loads on the elevators' top surface when the stabilizer is more nose down. (The 707 pitch/roll is not hydraulically powered.)
When the elevators are pushed down by air loads, the inboard tabs would already be down, keeping the elevators at neutral (no input required), otherwise the stabilizer effectiveness would decrease. And with any input, they would assist -- that's opposite the 737 at low-speed as noted earlier. The mechanism for the convertible function on the 737NG is seen in the following drawing:


Source: slideshare.net

At low-speed and with no hydraulics available for that mechanism, the tabs remain in the balance (assist) function -- move opposite the input, in order to the move the elevators as intended in manual reversion.
Finally, here are the different tab deflections during maintenance testing (elevators are up):


Source: b737.org.uk

To summarize: the lock is for the input (therefore no impeding action), and the tabs on the 737 do a lot behind the scenes.