The concern is not the screw backing off, although that might happen. The concern is that the screw is not strong enough, nor are your “safety stops” for towing a trailer, even at the lower DOT class levels. In addition the cornering force on something that is slack enough to get a gear motor to push it back and forth will bend and bind it in no time. Plus, normal screw thread just isn’t made for that. What you are describing is essentially a linear actuator. A ball screw would be a good idea. Lots of people make these. Tell any of them that you are going to build it into the tongue of a trailer (BTW, your first sketch showed it under the car, not the trailer) and see what their attorneys and engineers say. If you are up for thousands in machining costs, you might make something strong and precise enough to move back and forth like you want. It will be expensive, heavy, and a huge diminishing return. All so you can push a button to make your trailer longer? You are the only one who will be impressed by this. Just make a short trailer if that is what you want. The limitation on turning will not impact you in almost any normal paved road situation. The main issue will be seeing it. Put an antenna on the rear of the trailer.
Experience is not the sole purveyor of knowledge. Just because none of us have done this before doesn’t mean we aren’t looking out for your best interests, and those of the public. Personally, I’ve never contracted Ebola before. I still feel confident in stating it isn’t a good thing to do.