It’s not at all a thick question, and there are indeed those who would argue that the formless attainments are not included in the earliest teachings. To be clear, they are found, very widely, in the EBTs, and I disagree with the arguments that they are a later addition. Still, there is no doubt that the four jhanas are the central aspect of samadhi in the EBTs.
In the case, however, the distinction was made with lokuttara samādhi, which is quite different from the formless attainments.
The lokuttara jhanas are not really described as such in the EBTs, although there are a number of passages and references on which they are based. It seems that originally the idea was simple, and was established to distinguish between Buddhist and non-Buddhist practitioners of jhana.
Someone practicing jhana without right view (from the Buddhist perspective) has an experience of bliss and freedom, and after death will likely abide in a dimension of corresponding bliss. However this is not permanent and after some time they will return to this world or even to lower realms. This kind of samādhi is therefore regarded as lokiya “worldly” or “mundane”, but what it really means is “bound to the world”, i.e. “subject to rebirth”.
In contrast, one who, grounded on right view, realizes that same state of mind that we call jhana, will, due to the combined power of their samadhi and wisdom, break free of the chains of rebirth and find freedom. This is called lokuttara “beyond the world” or “transcendent” samādhi.
Over time, this distinction became more tightly constrained, as is the wont of the Abhidhamma, and the lokuttara samādhi was felt to be confined to, not just any jhana practiced by one of right view, but certain specific “mind moments” that occur on the occasion of realizing the noble paths and fruits. The path moments occur only once, as their function is to destroy the fetters, but the fruition moments may be re-entered in meditation by a practitioner. Certain descriptions of mysterious states of samādhi in the Suttas are said to be about such fruition attainments, especially for the arahant.