I frequently employ a similar tactic with my top pair good kicker type hands, or when I have a strong pocket pair like JJ and only 1 overcard flops like a Q.
This simultaneously pot controls, while gaining us value when villain bluffs.
Where I question your play, is your river play. I don't know why you would raise any amount in position on the river with a marginal hand unless you are trying to bluff out a better hand. If you are bluffing
that is fine...but if you think he is bluffing, then just flat call and bluff catch. This limits your losses for the times you are just wrong, or in the times that you were right, but then he sucked out on the river.
The other problem with raising the river is, even when you are correct that he is bluffing, the raise gives you almost no extra value since most bluffs will fold at this point. So it's all risk with little to no reward.
The third problem is that if you raise the river when you think he is bluffing and he smells weakness and re-bluffs YOU!! Now what?? you'll be sick with yourself if he puts you to the test for all your chips...you'll be cursing "Why oh why didn't I just flat call with 2nd pair?" It's a pretty big mistake, IMO to raise without a good clear reason on the river, as it can cost you the entire pot. Instead of raking in a nice 1,000 or so pot, you now lose 2,000.