It could be any one or more of several things.
The first thing to do... is once you get the motor to where you want it trimmed, disconnect the trim switch near the throttle/shifter. There shouldl be a connector within a foot of the shifter, under the console. If you have a side mount control box with a key in it, you will not be able to do this easily.
Sometimes the wires on the shifter get skinned and if the power lead and the up trim lead connect (as you are moving the shifter forward), it will cause the motor to trim up.
I that does not clear the problem, then disconnect the swtich that is on the motor.
If the problem goes away, you could have an issue with the skinned wires or you could have a corrosion problem in your switch.
There are some other places to check after this...but these are the most likely candidates.
Mike