Right. Now, if they were so smart, why did they go to Herod do begin with? Doing so resulted in the slaughter of the innocents. Yes, of course you could say "to fulfill prophecy," but I'm not sure really answers the question.
It wasn't that they were so smart, but they were warned not to return to Herod. See the previous sentence, which is from Matthew?
It is the fact that "warned in a dream not to return to Herod, they departed to their own country by another way" (Matthew 2:12).
Bethlehem is five miles south of Jerusalem. The direct route for Persian visitors would be to pass through Jerusalem. It was perfectly natural that they should call upon Herod - not to mention politically advisable.