In this position why shouldn't the knight capture the rook? The white knight is going to move to e6. However, the computer advises the rook to capture the pawn in b2. Even after the knight moves to e6, forking the queen and the rook, it advises to NOT capture either and instead go for the pawn c5 (see 2nd picture). Why is it a better move?

next moves from the analysis tab:
(Nxe6, Qd7, Nxc5)

and later
Black's idea is to play Re2+ at the right moment. If, for instance, White takes the rook with 19.Nxf8 Kxf8, there is no way to prevent Black from playing Re2+ later, winning the Queen (after Qxe2 Bxe2 Kxe2, not hopeless but slightly good for Black possibly; in practice Black might pick up g2 before doing this), reason being that Kf1 walks into a discovered attack. Because of that, White chooses to play 19.Nxc5 instead to capture the bishop on a6 and thereby prevent Re2+.
Although the difference between taking the rook or going for the bishop is not that big, both moves can be considered reasonable.
EDIT: In fact a deeper analysis reveals that taking the rook is in fact to be preferred since after 19.Nxc5 Qc6 20.Nxa6 d4! apparently leads to an advantage for Black, threatening Qxg2 and thus forcing 21.Qf3 after which Qxa6 now leads to a Black advantage due to having forced the enemy queen away  from the Queen side defenses. So I suppose you were right after all to consider 19.Nxf8 stronger.