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.
There is one exception to the above, and that is for OneWorld airlines. If you are arriving and departing on a OneWorld airline, then they will treat your two bookings as if they were booked on the same ticket, even when they are not. Some OneWorld airlines actually publish this fact (eg, it's on AA's websites) whilst others do not - but in theory at least, all of them should honor it.
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!
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.