difference between GameObject.Find() and FindGameObjectWithTag

Hello. I want to ask a question about the GameObject.FindGameObjectWithTag()
and GameObject.Find(“name_of_GameObject_in_Hierarchy”), that i came across in a Unity tutorial
here is the link to the tutorial Beginner Stealth Tutorial

With GameObject.FindGameObjectWithTag() i was constantly getting NullReferenceExceptions
while with GameObject.Find(),
( i.e replacing GameObject.FindGameObjectWithTag(Tags.alarm) and GameObject.FindGameObjectWithTag(Tags.mainLight) GameObject.Find(“lightunderscorealarmunderscoredirectional”) and GameObject.Find(“lightunderscoremainunderscoredirectional”) in Awake function ) , the scene was running like the tutorial. (the tutorial is part 06 of the Beginner Stealth tutorial, in Unity’s website, and i used the word underscore instead of the underscore symbol because it could not be seen in the preview for some reason)

Why was that happening?

Thanks in advance.

here are the two scripts

1.LastPlayerSighting script

    using UnityEngine;
	using System.Collections;
	
	public class LastPlayerSighting : MonoBehaviour
	{
		public Vector3 position = new Vector3(1000f, 1000f, 1000f);         // The last global sighting of the player.
		public Vector3 resetPosition = new Vector3(1000f, 1000f, 1000f);    // The default position if the player is not in sight.
		public float lightHighIntensity = 0.25f;                            // The directional light's intensity when the alarms are off.
		public float lightLowIntensity = 0f;                                // The directional light's intensity when the alarms are on.
		public float fadeSpeed = 7f;                                        // How fast the light fades between low and high intensity.
		public float musicFadeSpeed = 1f;                                   // The speed at which the 
		
		
		private AlarmLight alarm;                                           // Reference to the AlarmLight script.
		private Light mainLight;                                            // Reference to the main light.
		private AudioSource panicAudio;                                     // Reference to the AudioSource of the panic msuic.
		private AudioSource[] sirens;                                       // Reference to the AudioSources of the megaphones.
		
		
		void Awake ()
		{
			// Setup the reference to the alarm light.
			alarm = GameObject.Find("light_alarm_directional").GetComponent<AlarmLight>();
			
			// Setup the reference to the main directional light in the scene.
			mainLight = GameObject.Find(Tags.mainLight).light;
			
			// Setup the reference to the additonal audio source.
			panicAudio = transform.Find("secondaryMusic").audio;
			
			// Find an array of the siren gameobjects.
			GameObject[] sirenGameObjects = GameObject.FindGameObjectsWithTag(Tags.siren);
			
			// Set the sirens array to have the same number of elements as there are gameobjects.
			sirens = new AudioSource[sirenGameObjects.Length];
			
			// For all the sirens allocate the audio source of the gameobjects.
			for(int i = 0; i < sirens.Length; i++)
			{
				sirens _= sirenGameObjects*.audio;*_

* }*
* }*

* void Update ()*
* {*
* // Switch the alarms and fade the music.*
* SwitchAlarms();*
* MusicFading();*
* }*

* void SwitchAlarms ()*
* {*
* // Set the alarm light to be on or off.*
* alarm.alarmOn = position != resetPosition;*

* // Create a new intensity.*
* float newIntensity;*

* // If the position is not the reset position…*
* if(position != resetPosition)*
* // … then set the new intensity to low.*
* newIntensity = lightLowIntensity;*
* else*
* // Otherwise set the new intensity to high.*
* newIntensity = lightHighIntensity;*

* // Fade the directional light’s intensity in or out.*
_ mainLight.intensity = Mathf.Lerp(mainLight.intensity, newIntensity, fadeSpeed * Time.deltaTime);_

* // For all of the sirens…*
* for(int i = 0; i < sirens.Length; i++)*
* {*
* // … if alarm is triggered and the audio isn’t playing, then play the audio.*
_ if(position != resetPosition && !sirens*.isPlaying)
sirens.Play();
// Otherwise if the alarm isn’t triggered, stop the audio.
else if(position == resetPosition)
sirens.Stop();
}
}*_

* void MusicFading ()*
* {*
* // If the alarm is not being triggered…*
* if(position != resetPosition)*
* {*
* // … fade out the normal music…*
_ audio.volume = Mathf.Lerp(audio.volume, 0f, musicFadeSpeed * Time.deltaTime);_

* // … and fade in the panic music.*
_ panicAudio.volume = Mathf.Lerp(panicAudio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
* }
else*

* {
// Otherwise fade in the normal music and fade out the panic music.
audio.volume = Mathf.Lerp(audio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
panicAudio.volume = Mathf.Lerp(panicAudio.volume, 0f, musicFadeSpeed * Time.deltaTime);
}
}
}*

2.Tags script
using UnityEngine;
using System.Collections;_

public class Tags : MonoBehaviour
{
* // A list of tag strings.*
* public const string player = “Player”;*
* public const string alarm = “AlarmLight”;*
* public const string siren = “Siren”;*
* public const string gameController = “GameController”;*
* public const string mainLight = “MainLight”;*
* public const string fader = “Fader”;*
* public const string enemy = “Enemy”;*
}

GameObject.Find() searches by gameobjects name and FindGameObjectWithTag` searches by the tag assigned to it (in inspector there is a place you can assign tags) if you dont assign it the tag will be Untagged but you cant have no name so everyobject got a name

***********************(because forum doesn’t let me add another answer i add it here )

you can use static and it will work so whenever you wanna call a tag call it like this Tags.alarm or Tags.whatever

public static class Tags 
{
    // A list of tag strings.
    public static string player = "Player";
    public static string alarm = "AlarmLight";
    public static string siren = "Siren";
    public static string gameController = "GameController";
    public static string mainLight = "MainLight";
    public static string fader = "Fader";
    public static string enemy = "Enemy";
}

if you dont want static class you can make an instance of your tag class and assign it via inspector