There are many effects that allow players to ‘edit’ what a spell targets. There are also may spells and abilities that cause objects to change controllers. These are two very different kinds of effects and something that allows you to change the target of a spell or ability does not change who controls the spell or ability.
For example, let’s assume that in a two-player game Mind Sludge is initially cast by player A targeting player B. If player B uses Ricochet Trap to change the target of Mind Sludge to player A, player A will remain the controller of the Mind Sludge. This is important as Mind Sludge will count the number of swamps controlled by its controller. In this example, player A would discard cards equal to the number of swamps that he controls. The number of swamps controlled by player B does not matter at all in this situation.