rikus heart was being consumed by darkness since maleficent persuaded him in traverse town, his heart was getting weaker.
the keyblade couldent reach riku cuz of the darkness in destiny islands so it went to sora as the as riku said delivery boy lol. riku still was the master till holow bastion eg when sora met with riku again in hollow bastion it appeared in rikus hands.
and im guessing the darkness consumed him too much in hollow bastion and sora got stronger and it went bak to him....meh i dunno.