Buy this accessory for your ladder. It rests on the roof, not on a gutter or wall. It extremely safe as it won't allow the ladder to twist. https://www.homedepot.com/p/Werner-Quick-Click-Ladder-Stabilizer-AC78/100658388
It looks to me those would work well on certain stair wells also. Ours would be one.:thumbup1:If you are talking about a roof shape slope other than a flat roof, one method is leg levelers.