Welcome to iRV2.
What you're dealing with is a poor trailer ground situation , you can check by connecting a jumper cable from the trailer frame to the tow vehicle frame, if all the lights work correctly then you have to find the ground wire from the trailer wiring plug to the trailer frame and check for a good connection there.
Note sometimes removing or disconnecting a trailer's battery can disturb the ground wiring.
Is the trailer battery hooked up properly ?
If the wiring from the plug to the frame is good then you need to see if the lights on the trailer are properly grounded to the trailer frame.
EDIT; I guess I should explain why the signal/brake light work with the headlight/park lights off. With the headlights off the , signal/brake lights can back feed to ground through the park light circuit, when the headlights are on , that path to ground and any other partial path to ground are blocked , by the power flow from the park lights.