And the networks on both the sender's and receiver's side keep a copy of the messages for a certain time. Depending on local data retention laws, these may then be kept for some mandatory longer period.
Your local data retention laws and the network's practices may vary or they may be under pressure from law enforcement to keep things longer than necessary. They will not disclose in public how long they are stored, so better assume forever.