The friendship between Capybaras and these crocodilians most probably began with trauma. The crocodile tried to eat it, and realised he was eating an oversized rodent. He was traumatised. The capybara escaped with her injuries. And was traumatised. When the next met they gave each other a wide berth. Before long, they didn't even notice each other. They could literally just sit side by side in quiet trauma.