If I buy tickets from different airlines, can I somehow join them so that - in case of delay - connecting flights are guaranteed?
What if airlines are code sharing partners?
In general, the only way that you will be guaranteed to have the airline re-accommodate you on a later flight in the event of a delay is to book the flights on the same ticket - which basically means that you need to buy all of the flights together, from the same source. There is no means to "combine" them after booking, even if they are booked on the same airline!
Many airlines do not sell tickets for other airlines, so you will normally need to go through a travel agency to achieve this - either an online site or a physical travel agency.
Depending on the airlines involved it may not be possible to book the flights on the same ticket - it all comes down to which airlines have "interline" agreements with each other. A travel agency will be able to confirm details like that for you.
When making plans like this - especially if you can't get them booked on the one ticket - it's a good idea to have travel insurance as a backup. As long as you've booked a valid connection (ie, above "Minimum Connection Time" for the airlines/airport) then most travel insurance will cover the costs of being rebooked if you miss a connection - but obviously read the fine print first!
There is a website https://www.kiwi.com/ and if you buy through them, the tickets are a bit more expensive then if bought at the respective airlines directly or elsewhere, but Kiwi.com will guarantee (insure) your connection even if they are by different airlines/alliances, and the airlines themselves don't guarantee the connection. So in case a flight is delayed and you miss the next leg, you contact Kiwi.com and they will buy you a new ticket to get you to your destination.
Details of the guarantee are laid out here: https://www.kiwi.com/us/content/guarantee
In my experience, airlines generally will are rebook you in case of connection delays if they are codeshare partners (for example, BA and AA resell each others' flights across the Atlantic), or are in the same alliance. As always, frequent flyer status is likely to expedite this too.
I cannot say how much of this is "guaranteed" or legally required. I suspect very little.