Hi,
With a lot of radios the aux input socket has an internal contact which is operated when the aux cable plug is inserted. This sends a signal to change the input source.
Most likely if the socket is loose the contact connection or the wiring connected to it, is touching something that it shouldn’t, simulating a cable being inserted.
The radio would need to be removed from the dash and opened and the socket checked and made secure again or if broken then replaced.
What is the year model of the vehicle and is it the stock radio or after market one?