How i can make object hide and visible by collision with other object?

I make a cube object and attach main camera to the cube. Also I have another cube and cylinder in the area, so when I play, they should be invisible and after the cube or player has contact with object, it gets visible:

public class Player : MonoBehaviour
{
// Start is called before the first frame update
private float _speed = 1000f;
public GameObject yellow;
public GameObject red;

void Start()
{
    yellow.gameObject.SetActive(false);
    red.gameObject.SetActive(false);
    
}


// Update is called once per frame
void Update()
{ 
    CalculateMovement();
}
void CalculateMovement()
{
    float horizontalInput = Input.GetAxis("Horizontal");
    float verticalInput = Input.GetAxis("Vertical");
    float x = 5f * Input.GetAxis("Mouse X");
    float y = 5f * -Input.GetAxis("Mouse Y");
    

    Vector3 direction = new Vector3(horizontalInput, 0, verticalInput);

    transform.Translate(direction * _speed * Time.deltaTime);
    transform.Rotate(y,x,0);
    transform.rotation = Quaternion.Euler(transform.eulerAngles.x,transform.eulerAngles.y,0);
}
private void OnTriggerEnter(Collider other)
{
    if (other.gameObject.CompareTag("Collaborative_area"))
    {
        other.gameObject.SetActive(true);
    }
    if (other.gameObject.CompareTag("Dangerous_area"))
    {
        red.gameObject.SetActive(true);
    }
}

}

And I get confused for which object I should define collider and rigidbody?

The main error I see there is that you disable red and yellow (in the Start method). So you disable the whole GameObject, including its child game objects and every component attached to them. This is why OnTriggerEnter never fires for red and yellow.

Instead of disabling them in the Start method, I would write something like red.GetComponent<MeshRenderer>().enabled = false inside the Start method, and
red.GetComponent<MeshRenderer>().enabled = true inside the OnTriggerEnter method, in the if statement.

And about your question about colliders and rigidbody settings, I suggest you take a look at Unity - Manual: Introduction to collision
At the very bottom of this page, you’ll find a table that shows what combination of collider and rigidbody settings trigger what functions.

Hope this helps !

Yes, thanks it works. I have an another questions, I use my yellow cube as transparent material, I want to when I enter to the object it gets visible and show it in game mode. The visibility works by your guidance, as you can see in image it show up in the scene but when enters the object , it disappears from game mode. Somehow it looks like it just show surfaces!