Why does this make my object switch rotate directions when rotated 180 degrees

Quaternion newRotation = object1.rotation;
newRotation.y = transform.rotation.y;
object1.rotation = newRotation;

when I rotate 180 it rotates in a different direction

Quaternions cannot be manipulated same as normal angles.

When you are setting rotation.y it’s not same as setting the y-axis rotation.
Quaternions use 4 dimension (x,y,z,w) to represent the rotation and unless you have very good understanding how to manipulate the Quaternions directly its not gonna work.
Unity’s Quaternion has it’s own methods, properties and operator overloads (like multiplication with vector) to help the rotation manipulation.
However if you just need to set rotation values like in the Inspector (Normal mode) then you can use eulerAngles (like transform.eulerAngles) to set the angle values directly.

I’m not sure what you are trying to achieve but if you want to set the object1 (I assume the objet1 is Transform of some other gameobject) rotation angle value for y-axis same as this-objects value, you do it simply like this:

object1.eulerAngles = new Vector3(object1.rotation.eulerAngles.x, this.transform.rotation.eulerAngles.y, object1.rotation.eulerAngles.z);

Check also this to set more info: Unity - Scripting API: Transform.rotation