An AirTag has no means by which to locate itself, or directly communicate its location.
An AirTag in simple terms is a beacon - that transmits a unique identity over a short range, using a Bluetooth Low Energy (BTLE) radio signal. This signal can be detected by other Apple devices (e.g. an iPhone) that are within about 10m (30'). The detecting device anonymously reports the unique identity of the received signal, along with the known location of the detecting device, to Apple's backend servers. As the AirTag will be with 10m of the detecting device, the reported location will be within 10m of the reported location.
Unless an Apple device "passes by" within range of a transmitting AirTag, the AirTag's reported location will not be updated.
If you have an Apple device in close proximity that is (a) participating in Apple's Find My network, and (b) the AirTag that is not showing its location, this would imply that the AirTag is faulty or has a failed or unsuitable battery.
Be aware that button cell batteries are coated with a bitterant substance ("Bitrex"), this foul tasting substance being intended to dissuade children from swallowing the battery. This bitterant can prevent the battery from making good electrical contact with the AirTag's battery compartment. When replacing a battery, ensure that you have selected a battery that does not have a bitterant coating, or the manufacturer has explicitly stated that the battery is compatible with AirTag. Some (but not all) CR2032 batteries manufactured by Duracell are marked as being compatible with AirTag.