Assuming that the white king can go f5, then the black king takes it, and then the rook takes the black king. Now both kings of both sides are lost, so what rule should be applied to such a situation?
White should be able to move king to f5. Why am I wrong?
so I just want to know why I'm wrong here
The official answer
1. Both FIDE and USCF rules prohibit any king from putting itself into check. So two kings may never be on adjacent squares.
2. Both FIDE and USCF rules are very clear that any piece (including kings), need not have to be able to move in order to threaten another piece or guard another piece of the same colour.
Thus a pinned piece may still deliver check or guard another piece even though it is incapable of moving itself.
Equally, a king is able to guard another piece giving check even though it cannot move to the square the guarded piece sits on.
In a nutshell, a piece's ability to exert control over another square, are not diminished by the fact of it's inability to actually move to that square.
The logical answer
Your question suggests that the black king cannot capture the white king because he would be putting himself into check. That is the same logic that prevents the white king moving to f5 in the first place, if one follows the rules of chess above.
Rules apply evenly to both sides, you cannot allow white to play an illegal move, because somehow black is not able to do the same.
I know what you're thinking. The king's moving into check, that's illegal. But wait, is it really check? If the king moves to f5 and smooches the black king, he is in a completely 100% safe spot, and is therefore not in check. The black king is not attacking the white king because the BLACK king would be moving into check thanks to white's rook. Since the black king cannot take the white king if it moves to f5, the white king shouldn't be in considered in check, and can therefore be able to move there legally.
Obviously, Chess.com disagrees and I know that some kid isn't going to come on top in this scenario, so I just want to know why I'm wrong here, not whether I am wrong or not.