Here's the formula, where:
a = the length of the side/edge of the base
h = height

V= \frac{h}{3} a^2\\or\\V= \frac{ha^2}{3}

Both are just the same. ☺
Here is the formula of finding the volume of square pyramid:

A square pyramid is a polyhedron with a square base and 4 triangular faces. All the triangular faces meet at a single point called the apex. The faces of the pyramid connect the bases with the apex. Volume of a Square Pyramid is the measure of the number of units occupied by the pyramid.

The Volume of a Square Pyramid Formula is,
1/3 b²h

b is the base length of the square base of the square pyramid.
h is the height of the square pyramid.
s is the slant height of the face of the square pyramid.