How did Mello know how to help Near in Death Note? In the end of Death Note, Near would've been lost if Mello didn't help him. That makes me think why Near who is always be careful (isn't like L or Mello) didn't find out about the possibility of fake death note, meanwhile Mello had found out about that.

For Mello, after he found out that Kira helped Japan Police, he would found out that Kira was there being watched by others. In order to keep killing people, he would need X-Kira (Mikami) to do the killings and a spokeperson (Takada) to help him communicate with him. Until then, Mello's and Near's thinking were the same: find the x-kira (Mello investigated Misa too). Mello could easily assume that Near had found the x-kira and been stalking him.

What makes it weird is Mello thought that this person who was being investigated by Near was using fake death note, and assumed that Near wouldn't ever found out about this unless he kidnapped Takada.

So, would Near have never found out about the possibility of fake Death Note without Mello sacrificing himself? If it was really that hard to find out, how could Mello know? Doesn't it sound like Near would get easily be tricked by Light, while Mello outsmarted the two of them?
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.