State and event data is stored for 10 days by default. See:
LTS (long term statistics) is down-sampled to hourly max, min, average and kept indefinitely. Only entities with a state class have LTS.
Using InfluxDB to store data is independent from home assistant. You can set your own retention policies and usually Grafana is used to visualise the data. Speedrun setup: