Just like dogs, often rats urine mark.
They don’t do this because they urgently have to pee, and just cannot hold it in!
Rather, like with dogs, it seems to be a form of social communication and marking of territory. They seem to be saying “I was here. This is part of my territory. This belongs to me.” That thing might be their cage, hammock, toy, or another rat (where it might also be a show of dominance as well as friendship.)
They will even do it to you: I know that sounds kind of gross, but try to take it as a sign of affection!
When you put a rat in a new cage, especially a male, don’t be surprised if the rat immediately starts peeing over every accessible surface.
Male rats do it more than female rats, but both sexes will urine mark. Roof Rats mark, too, but not as much (they are smaller, which also helps with that!)
Some say that neutering might reduce marking, but I, personally, cannot vouch for that.