Samurai is defined as being a position in which he assumed the responsibility for a society as a whole.
They will fight for their master and support him as long as they live. It is called as Bushido.
The one who has this beautiful Master-servant relationship and Bravery and who risks his own life for serving his master, is a Samurai.
In the beginning, Samurai was a government official.
In the age of civil wars, gradually they became warriors having skill of martial arts.
This is the Samurai that we know.

Samurai participated actively in age of civil wars.

They kept fighting till the last of the Sekigahara battle.

After Sekigahara battle was ended, Ieyasu brought peace to his country.
Samurai did not need to fight any more, and at last, Meiji Era had begun.
But their spirit is still there in our heart.