How to know when my smartphone is EOL?
The only way easy way to have a phone with current software is to buy from one of the 4 companies (Google, Honor/Huawei, OnePlus, Xiaomi) that bother to keep older devices up to date;

https://www.xda-developers.com/list-android-devices-project-treble-support/

so that the OS will notify you of updates when they are avalable.
You can double check by cross referencing the kernel version and android security patch level with

https://www.kernel.org/

https://source.android.com/security/bulletin

Lineageos is a nice alternative for unsupported phones but is not without  issues;

https://web.archive.org/web/20170517160235/https://cve.lineageos.org/