It was just a PR stunt. He has elections to fight in a few months.It is a huge thing for a cricketer that the PM of their country is visiting them after a huge loss at the final of the World Cup and consoling them. Good gesture
There are more professional people like former cricketers and team psychologists etc who can "console" a team after a defeat.
If you follow Indian media, you'd know Modi loves limelight, and he loves shaking hands. If he was really there to console, he should have asked cameras to be off and made a small pep talk, and leave filling the environment with good feelings.
You could see Rohit and Kohli were very uncomfortable with his gestures. No one got "consoled" by his shaking hands.
Australian team celebrations were also delayed with captain waiting on the stage because Modi wanted to shake everyone's hand. And it is a country where a pranam from afar is a cultural norm.