how do i make sure both www.example.com and example.com lead to my home page in Apache2? [duplicate]

Your issue is with DNS. Yes, you should add and simple A record so that the www prefix also resolves to the same ip address as example.com

Example from my local DNS:

;
; BIND data file for smythies.com
;
$TTL    604800
@       IN      SOA     smythies.com. doug.smythies.com. (
                        2021031901      ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
                IN      A       192.168.111.1
;
@               IN      NS      ns1.smythies.com.
ns1             IN      A       192.168.111.1
www             IN      A       192.168.111.1
s15             IN      A       192.168.111.1
test            IN      CNAME   ns1
mail            IN      CNAME   ns1
Wireless-R      IN      A       192.168.111.57
dwifi           IN      A       192.168.111.58
doug-xps        IN      A       192.168.111.100
...