Origins of bond and spin order in rare-earth nickelate bulk and heterostructures