If using an external device, such as a combined dock-device, it may have multiple interfaces - such as 3.5mm analogue audio, HDMI (with or without HDCP), USB Type A, USB-C, or other interface (SD, microSD, LAN etc.)
The manufacturer of the dock-device will decide, through their own hardware and firmware implementation, whether or not their on-device interface(s) are selected when (a) by default the dock is connected to the iPad, or (b) when a physically connecting a cable - or other device (such as Headphones) - to the port/external-interface of the dock.
As such, given the possible variations amongst third-party hardware manufacturers, I cannot provide a definitive answer applicable to all available hardware. However, given your reported experience, the dock-device that you have selected appears to default all audio routing to itself. If you wish to change this behaviour, you may need to source an alternative dock - having first verified (and perhaps tested) that it is compatible with your needs.