What Ansible does in cases there's a conflict between OS version and some software Ansible manages? Say I use an IaaS cloud on which I installed Ubuntu 18.04 manually via the cloud company's OS installation tool and I ought to establish an all-ansible LAMP environment that will include some more stuff besides Apache, MySQL, and PHP (like `php-cli, php-curl php-mbstring, php-mcrypt, php-gd, Certbot, ssmtp and so forth) -- all installed with Ansible as well, of course.

So far so good, but what if after 4 or 8 or 12 years the particular Ubuntu rlease (18.04) becomes too old for a newer version of whatever software I installed with Ansible and also and constantly being upgraded by Ansible?

How Ansible itself deals with such a rare (?) conflict, does it usually do some "rollback" to a "previous state" (just like an autosave and autoload for video games) and also stops to work (and maybe also prompts me) until I myself decide if I want to remove this particular software (or softwares) that cause trouble and then start the Ansible process again?
Ansible is at its core a programming language - a meta programming language written in python compiling itself into python and shell scripts mostly. It will do whatever you program it to do. It all depends on how your roles and playbooks are written. It certainly can be done - almost anything can be done - your install roles could track dependencies on package versions or ranges, obviously those might need to be updated over the years, but you can be safe if you put the work into it.

It is probably unreasonable to plan further than the End of Life of the LTS distribution though, as you will fail to receive new security updates and that instantly invalidates the system as production ready.