first i would check it out by putting power directly to the motor.
Mine was intermittent trimming up. It turned out that the trim limit switch wiring had gotten damaged under the bell housing and was shorting out. Does trailer trim work ok?
If its not wiring then there used to be a rebuild kit out there but supposedly discontinued. I found one at a small mercruiser dealer.