The buffer cushions and slows the rearward thrust of the bolt and carrier assembly when the rifle is fired. It has a number of solid steel "slugs" inside that slide loosely back and forth, diverting the recoil forces. The nylon plug is to cushion the assembly from battering against the rear of the buffer tube.
The flat end, rests against the bolt carrier. The nylon end, is inserted inside the recoil spring. Spring and buffer are both inside the buffer tube, which is inside and supports the buttstock
Life ain't worth living, if ya ain't got a good cigar.