All of this works because of the SIP protocol. It is a standard widely used by ISPs, VoIP phone systems and VoIP phones world-wide. It makes expensive proprietary phones obsolete, and helps that all devices can talk to each other.
IP phone systems are usually built on standard PC or embedded hardware which are more cost-effective and powerful than the hardware of the traditional phone manufacturers. At the same time, ip phone systems are scalable, as they are not limited to a certain number of physical phone ports. That means you don’t need to replace your phone system when your company grows.