I see often the variable type Transform, what it is used for. Why not using Gameobject. Thanks
You can always get the Transform from a GameObject by using
myGameObject.transform
You can also always get the GameObject from a Transform by using
myTransform.gameObject
So you could say it doesn't matter much which one you use. However, you can specify the variable as a Transform if you want to put emphasis on the alignment of the object.
Also, using the myGameObject.transform property is an expensive operation that should not be used each frame if you care about efficiency. Instead, you can do it just once in the Start method and store the Transform in a variable, but this is not needed if the variable you got it from was of type Transform in the first place.
Transform is a component on a gameobject that describes its position in space. It's the only obligatory component for a gameobject to have.
One could argue it should be part of the gameobject, but... it isn't :)
is that true for accessing transform from within a MonoBehaviour script as well?
Yes, it's the same as if you created a public "transform" parameter and then dropped the GameObject onto itself. It's so common, though, that they predefine it for convenience.
One thing I'd pay attention to is that the transform's default getters/setters (transform.position, e.g.) operate in world-space and may have matrix-multiply side effects. So the two things to keep in mind is that (i) if you want a local transform (i.e. relative to parent) you'll need to set .localPosition/.localRotation/etc, and (ii) if you are setting the world-space value be sure to just "get" it once and then "set" it once, instead of thrashing back and forth.