That formula only works for a regular polygon - all sides equal.
The perimeter of the given hexagon is 24.
The apothem is a line segment drawn from the midpoint of a side to the middle of the hexagon. The apothem, 1/2 the base, and a line drawn from the middle of the hexagon to the vertex of the same side from which the apothem is drawn forms a 30 60 90 triangle. 1/2 the side length is the side opposite 30. And 1/2 the side length times square root of 3 is the the apothem (side opposite the 60 degree angle).
For this hexagon the apothem is