How did Mello know how to help Near in Death Note?
I remember that Halle Lidner, SPK member, always kept in touch with Mello, keeping him up-to-date with Near's latest theories concerning Kira case. It's possible that he also knew about Near's plan and his appointment with Kira.

However, Mello, with Matt, decided to kidnap Takada that made the real Death Note location revealed.

Before that, Mello's movements are unknown since the story focus on Takada and Mikami investigation. His reason to kidnap Takada is also unknown whether because he realized the possibility of fake Death Note or other reason.

But in the end, Near acknowledged Mello that he wouldn't have won without his sacrifice.