The lights connect to ground thru the nuts(one of /both of) that mount it to the metal trailer. Once the nuts get rusty, you lose ground. You can try running a ground wire all the way from the white wire to the nuts. I have had success with that approach in the past
Now, you say they are brand new....
Since all trailer lights are made in China, overtightening that nut causes the bolt to spin and ground (internal to the light) to be lost or intermittent.
Solution, THERE IS NONE. TRAILER LIGHTS SUCK!
Get used to it. You're a boat owner now...
P.S. Once you think you have it fixed, try turning on your headlights and check again.