Instance “B” resides in the public subnet but does not have a public IP address. Therefore, it cannot communicate directly with the internet for updates unless it uses an intermediary like Instance “A” as a NAT instance (not mentioned in your setup). To get rid of that error you need to assign a public IP to “B” if it needs direct internet access.
If Instance “B” lacks a public IP, it won’t be able to use the IGW, even though the route table is correct.
Or you can configure instance A as a proxy or NAT instance to allow B to access the internet without the need of a public IP.
and Ensure “A” has IP forwarding enabled and correct routing setup.
(even if instance in the public subnet, if it doesn't have a public IP you need to treat it the same way as an instance in the private subnet)