Golf has some funny rules. Some make sense. Some don't. And some make sense in part and don't at all otherwise. One example of that last type of rule is how golfers handle when two golf balls collide on the golf course.
Whether it's on the green,or in the fairway, rough or sand, the Rules of Golf addresses what to do when two balls hit each other. However, how the rules are applied actually depends on where both balls were before the collision occurred. (And now you can see why this rule isn't always the best.)
If just one ball is on the green
If neither ball or just one of the two balls is on the green when the collision happens, then good news! You don't get a penalty under Rule 18-5, which says that when a collision happens between two balls and both aren't already on the putting surface that the player whose ball collided with the ball at rest plays their ball wherever it ends up stopping. As for the player whose ball was struck, they're to return their golf ball to as close as they can to where it was before the collision and play from there with no penalty.
However, the player whose ball was struck can incur a two-stroke penalty in stroke play or loss of hole in match play (which is kind of insane) if they don't move the ball back. If neither player saw the collision and couldn't have known about it, there's no penalty for not moving the ball back.
If both balls are on the green
If both balls involved in the collision are on the putting surface already when the shot that leads to the collision is struck, then we might have a problem for the person hitting the shot. In match play, under Rule 19-5, there is actually no penalty for the collision. In stroke play, though, there is a two-stroke penalty to the player who hit the shot that led to the collision with the ball at rest.
Under this scenario, the same thing still happens to next shots. The player whose ball was struck while at rest replaces their ball at the original position and plays without penalty. Meanwhile, the player who hit the shot to lead to the collision plays their ball where it ends up post-collision.