I get the same thing happen to me all the time.
I've been looking for trunks that are long enough to stop them from riding up ( about the length of cycling short I think )
In the mean time i've tried particularly shor tboxers, and find they work well, slthough they do ride up, there's not so much fabric to get bunched up.
At the moment i have a good pair on, Thomas Nash trunks with the "letterbox" opening at the front. they seem to work pretty well for me.
So in the absence of being able to go long, try going short, but not briefs.