It just happens. Usually the friend shares an interest. But shared interest is not enough. The friendship is bonded by mutual trust. It may lead to the opposite.
Many criminals have strong friendships, solid in shared interests and mutual trust.
The Greek name for the third kind of love is 'eros'. It is what we think of as ' romantic ' love. It is not necessarily physical. It may be an intense infatuation that never results in a physical relationship. It may be an intense infatuation that is never reciprocated.