If the UDP packet's header is a fixed 8 bytes size, how it does not contain a field for TTL, How traceroute put that field ?
UDP datagrams are carried in IP packets. The IP packet header will have that field: TTL for IPv4 or Hop Count for IPv6.
UDP datagrams do not travel unencapsulated across a network (no IP addressing in the UDP header, either), and they are only relevant inside the host. The UDP datagram will be unencapsulated from IP and passed directly to the UDP process, so there is really only one hop from IP to UDP.
There is really no TTL concept for UDP.
Commands and apps like traceroute take advantage of normal IP behavior. They play with TTL field in IPv4 (Hop Count in IPv6) by replacing it with 1, instead of default values of 32, 64, etc.
First router decreases it by one, hitting a zero in TTL value, thus dropping the packet and returning an ICMP TTL Exceeded back to your host, which results in disclosure of IP address of the first router.
Then traceroute sets TTL=2, TTL=3,... so on so forth.
Not all implementations of traceroute use UDP. Actually some default to ICMP. But it doesn't matter whether UDP, ICMP, or even TCP being used as a transport (in case of no restrictive firewalls) the result is the same most of the time.
The important parts are TTL in the header of the sent IP packets, and the source IP address in the replies.