initialization of script member variables?

Good day everyone,
I am a unity beginner, I have just finished my first 2D tutorial project and I am enjoying unity a lot so far. however I am still confused about how scripts get instantiated for each game object.

the tutorial I have done is here: Creating a 2D game with Unity — Pixelnest Studio

every OOP project I have worked on so far (C#, C++, java) has told me to declare most fields private and create public get methods (accessors in C#).

that convention aside, lets look at the following two examples:

example 1:
Class A {
public int x = 5;
}

example 2:

Class A{
public int x;
public A(){x=5;}
}

I have always considered the latter to be better practice (especially when working with other constructors), but in the tutorials I have encountered the trend is to declare fields like the former.

why is that a source of confusion?
tutorial asks me to do something like this:

class AScript : MonoBehaviour
{
public int x = 5;
}

then it asks me to attach a seperate AScript to different gameObjects using the IDE.

now if the different game objects used the script in exactly the same way I would not be confused but:
I am encouraged to use the inspector to change the initial value of x to different values for different game objects.
This is very disconcerting for me because I somehow have multiple Script classes with the SAME name and I am changing initialization values of x in a very dirty manner.

it seems to me like I have

class AScript : MonoBehaviour { public int x = 5; }
and
class AScript : MonoBehaviour { public int x = 6; }

in the same project which I dont even see how this is legal. Granted, this form of initializing fields is something I have not often dealt with so much (except static fields that belong to class), and I am not aware of how the compiler handles it (if it translates it to a constructor call or whatever)

I would be MUCH happier if I could write something like this:

class AScript : MonoBehaviour
{
public int x;
public AScript(){x=5;}
public AScript(int input){x=input;}
}

and then use the inspector to change constructor arguments for each instance of AScript created for my game objects (as opposed to changing the class that has the same name?)

Thank you so much in advance for shedding light on this topic and please dont hesitate to ask for more details if needed.

Regards
Phil

Firstly, you should use code sample functionality if you want to include code in your questions.

You are right it may be counter intuitive for a starter but the class initialization and compiling is not done as you think. Simply it works like this in Unity:

All objects you see in scene hierarchy are called game objects and they are an instance of GameObject class. You can attach components which derive from Component class to game objects. These are what you see in inspector. A MonoBehaviour class is (inheriting from Component) used to add functionality of Update, Start etc. When you add a component on a game object, you are not copying the script, but you are creating an instance of it. So the constructor is called at this stage. When you change values in the inspector, you are changing values of an already instantiated class instance. You can test this yourself by putting Debug.Log s at Constructor, Start, Update etc. If you want to change values at game start, you should do it in Start function.

Also I don’t think it is good practice to put variable initialization in ctor. It simply doesn’t matter where you put it (for class types it may matter). But in Unity, you shouldn’t use Constructors as behavior will be unpredictable. For example try adding a ctorwith parameter but don’t add a parameterless ctor. You will get error when you attach this to an object.