This is a perfectly legal, and quite common tactic.
The Monopoly card has no play restrictions other than the typical "once per turn, not on the turn you got it" Dev card restrictions. It affects all resources of the named type in play, regardless of how long the other players have owned those resources. Trading resources away and then Monopolizing them back is therefore perfectly legal because there is no rule against it.
There is a cost in player interaction, though
If the other players feel that you've taken advantage of them, they may stop trading with you. Whether this cost is enough to make you skip this tactic depends on where you are in the game. Trading typically drops off near the end anyways, as it becomes obvious that trading with the lead player will help them win more than it will help you catch up. Stealing their resources with bad faith trades merely runs the risk of cutting off your trades sooner rather than later.
Of course, if the other players really feel that this tactic is unsportsmanlike, they may stop playing Catan with you. Some players don't enjoy aggressive play styles, and playing aggressively is incompatible with playing with them. This is going to vary depending on the social contact of each specific game group (some players will dramatically declare unending revenge if you pull this on them, but consider it part of the game and would happily do these same to you, while others are genuinely bothered by it) and is something you will have to judge for yourself.