Part of it is certainly about projecting an image to the people at home, but I think it’s helpful to remember that the Opposition leader is (typically) an MP as well, and meeting with international leaders is an opportunity to learn and share with your counterparts.
All foreign visits should be done at the behest, or at least cooperation with, Foreign Affairs. Anything done without their approval is only done in self-interest and frowned upon.