The EC2 instance can be created by different types of OSs. If you want to create an EC2 instance with apt-get, try to create it from ubuntu AMI which is ubuntu 20.04). The one you have is based on Centos or Redhat, which are using yum as a package manager not apt.