Competition between phase separation and spin density wave or charge density wave order: Role of long-range interactions