I had a looping flow and I figured out it was because the flow updated an item in the same list as the trigger for a created/modified item.
I have a dedicated account for automated flows so I am able to exclude a flow from running if it has been edited by the dedicated account like so:
@not(equals(triggerOutputs()?['body/_modifiedby_value'],'123451c6-8888-ec11-98ef-002248041234'))
Note: the GUID above a user is the CRM 365 system which is different than the Azure GUID so change the GUID to match the correct account in your scenario.
The above code is entered on the trigger by clicking the three dots on and go to Settings:
Scroll to the bottom and click Add under Trigger Conditions and paste the expression code there
(This image does NOT have the correct code entered and is only for reference)
My flow was for CRM 365 Notes (Annotation) entity. I also wanted the flow to only start when an attachment was added so I added the following code on another line:
@equals(triggerOutputs()?['body/isdocument'],true)
Reference: https://medium.com/@gurdevluck/prevent-infinite-loop-in-microsoft-flow-power-automate-b3cf9d764926