why does the texture gets stretched on my rectangle shaped object?
The stretching is happening because your model's polygons are rectangular, but the UVs are square. Apply Scale to the object before UV unwrapping.

To apply scale, select your object in Object mode, then go to Object > Apply > Scale (or CTRL + A > Scale)