Newton's third law: when two bodies interact, they apply equal but opposite forces on one another.
Whenever you go to apply this, you have to be really careful that you're consistent about which two bodies you're talking about.
The weight is the force that the Earth as a whole applies to the box. It has nothing to do with the ramp. By Newton's 3rd law, the box also pulls the Earth up a tiny bit, but we're ignoring that in this problem because we're not considering how the Earth moves, and besides a little box barely matters to the Earth's motion.
So the interaction we're concerned about in this problem is between the box and the ramp. The box pushes down and to the right on the ramp, and the ramp pushes up and to the left by an equal amount. That satisfies Newton's 3rd law.
We choose to decompose the weight vector into components along the ramp and perpendicular to the ramp in order to make it easier to solve this problem. The box is not accelerating through the ramp, although it may slide along the ramp. That tells us that the force components directly into and out of the ramp must be balanced. I.e. they must add to 0. Only the components along the ramp may or may not be 0, depending on whether or not the box is sliding.