How to install two mysql instance on same machine
You must have separate data trees and my.cnf files and Ports.  Your client(s) must pick the instance via the Port number.  That's about all you need to know.

You may use different binaries.

You may use VMs or Docker or ...  These may confuse the issues of Ports, binaries, etc, since they chop up your machine is ways that sort of give you separate logical machines.

There are several questions on this forum relating to this, and they discuss details for what to do before 5.7.6.