For BGP loop prevention between different ASs, or ISPs, which is a very important notion to understand when u are confronted to build a network with multihoming, redundancy and link failure options, plz read the following pages. As-path attribute allow ebgp loop prevention.

However the concept of BGP loop between ISPs or different ASs is very tricky since this is not something that you can experience in your own network. You will be more likely victim of it, particularly if your traffic engineering redundancy case has not been fully tested.I will even say that ebgp loop prevention is mainly related to peering agreements betweens ISPs.

This is deeply explained though the tutorial, but the four following sections are sufficient to make a clear outlook.