How network devices affect TTL
Solution 1:
TTL is part of the IPv4 protocol (on v6 it is called "Hop Limit", as per Steven Monday's comment). Switches and hubs operate on a different layer of the ISO/OSI model (layer 2 as opposed to layer 3 - there do exist so-called layer 3 switches, but I assume you're not asking about them as you include hubs as well).
The TTL field is set by the sender of the datagram,
and reduced by every host on the route to its destination.
http://en.wikipedia.org/wiki/Time_to_live
A switch or hub isn't a host on the IP protocol sense - they usually don't have IP addresses. If they do (in the case of switches) they are for management purposes and don't really take part in the actual functioning of the device. Switches work with MAC addresses instead, mapping them to ports and "routing" the packet only in the sense of sending it down the right port (hubs do much less work and send them through all ports instead). They don't inspect or alter the IP payload - you could be using other protocols as well.
http://en.wikipedia.org/wiki/ISO_model
Solution 2:
In a nutshell, Time To Live was implemented to prevent routing(OSI Layer 3) loops. That is to prevent a packet from hoping forever between the same nodes without ever reaching its destination. So only the nodes that make a routing decision for the packet decrease its TTL by one. When TTL reaches zero then the packet is dropped again only by a device making routing decisions.