Establish a system of reference with origin in the center of the square such that the diameter AB lies on the x axis.
(a) For every x in (-a,a) the plane perpendicular to the x axis intercepts the solid in a square whose side has the length of the chord orthogonal to AB in the point (0,x), which is:
l = 2sqrt(a^2-x^2)
So the area of the square is:
S = l^2 = 4(a^2-x^2)
The element of the volume of the solid generated by such squares between x and x+dx is then:
dV = l^2dx = 4(a^2-x^2)dx
Integrating over the interval:
V = int_(-a)^a 4(a^2-x^2)dx
using the linearity of the integral:
V = 4 a^2 int_(-a)^a dx -4 int_(-a)^a x^2dx
V = [4 a^2x - 4x^3/3 ]_(-a)^a
V = 4a^3 -4/3a^3 +4a^3 -4/3 a^3 = 16/3a^3
(b) In this case the length of the base is the same, so the area of the triangle is:
S = sqrt3/4 l^2 = sqrt(3)(a^2-x^2)
and the volume is:
V = int_(-a)^a sqrt3 (a^2-x^2)dx = (4sqrt3)/3 a^3