I created 2 VMs in the same availability set, and added them to a basic load balancer, and that worked fine.
Then I tried to do the same thing, the only two differences being that the VMs were not in an availability set, and I used a standard load balancer instead of basic.
One difference I noticed is that a standard load balancer will allow you to add VMs to the backend pool even though they are not in an availability set.
However I found that I could not connect to the machines through the load balancer's public IP address. Instead I get a connection timeout error. Why is that?
You are absolutely correct.
Basic SKU Load Balancer supports Virtual machines in a single availability set or virtual machine scale set as a Backend pool endpoints
Standard SKU Load Balancer supports Any virtual machines or virtual machine scale sets in a single virtual network as a Backend pool endpoints
https://learn.microsoft.com/en-us/azure/load-balancer/skus
To have possibility to connect to Virtual machine via load balancer's public IP you have to configure port forwarding in Load Balancer.
https://learn.microsoft.com/en-us/azure/load-balancer/tutorial-load-balancer-port-forwarding-portal