Magnetic and structural transitions in layered iron arsenide systems: AFe2As2 versus RFeAsO