**Solution 1**
The length of the path traveled by P is 14pi/3.

I drew a bunch of pictures to figure this out. Basically I drew the
triangle in the square as it rotated, with a new picture for each new
position of the triangle. Then I drew in the paths (in red) of how P
moved. The picture shows that sometimes P moved a lot, sometimes it
didn't move at all when the triangle rotated, and sometimes it moved a
little.

I noticed that there were two different movements done by P. Both of
them are arcs of a circle, since you are rotating a segment (a side of
the triangle) around a point, which makes a circle. For the big ones,
P rotates 120 degrees (I know this because the angle of the triangle is
60, which leaves 120). 120 degrees is one third of a circle (which is
360), so those paths are 1/3 of the circumference of the circle. There
are three of them, so that gives us 1 circumference.
P also moves in small arcs. These are rotations of 30 degrees, which
is 1/12 of a circle (360/30 = 12). There are two of those, so that is
2/12, or 1/6 of a circumference.

When we add them together, we have 7/6 of the circumference of the
circle. This circle has a radius of 2 (since that is the length of the
side of the triangle), so the circumference is 4pi (circumference = 2 *
pi * r, and r is 2). 7/6 of 4pi is 14pi/3.

**Solution 2**

The length of the path is (14pi)/3 inches. For the bonus, the answer
is 40pi/3 inches.

I made a picture that shows all of the different positions of P, and
then I drew in paths (the dotted red lines) each time P moves.

P is moving along the arc of a circle each time, because BP (or AP,
depending on which rotation it is) is like the radius of a circle when
you rotate around B. Since each arc will be part of a circle, we can
find the circumference of the circle, then figure out how long each arc
is.
circumference = 2 * pi * r = 2 * pi * 2 = 4pi

The first time P moves, it rotates 120 degrees around point B. I know
that it's 120 because angle PBA is 60, so angle PBX must be 120 (since
the whole thing is 180). To find out what part of the circle this is,
we divide 360 by 120, which is 1/3. So the first time, it moves 1/3 of
the circumference of the circle.
1 4pi
--- * 4pi = -----
3 3

The second time it moves it also goes 120 degrees, so that is another
4pi/3.
The third time it moves it only goes 30 degrees. I know that it's 30
because angle XYZ is 90 degrees and the the angle of the triangle is
60, so that leaves 30. We divide 360 by 30 to find that this is 1/12
of the circumference of the circle. The length of this arc is 1/12 *
4pi, which is pi/3.

The fourth time it also moves 30 degrees, so that is another pi/3.

The fifth time it moves 120 degrees, so that's 4pi/3.

Now we have to add them all up to find the total length.

4pi 4pi pi pi 4pi 14pi
----- + ----- + ---- + ---- + ----- = ------
3 3 3 3 3 3

This is all in inches, so the final answer is 14pi/3 inches.
For the bonus, I found that it's 40pi/3.

To do this, I made two more pictures - you have to rotate the triangle
around the inside of the square two more times to get the vertices of
the triangle back in their original positions. I will list out the
amounts that P moves each time you rotate the triangle - some of them
are 0 because that is when you are rotating the triangle around P, so
it doesn't move. There are eight "measurements" for P during each trip
around the square because that's how many times you have to rotate the
triangle to get it back where it started.

Rotation 1 (which goes with the picture in the first part):
4pi 4pi pi pi 4pi
----- + 0 ----- + ---- + 0 + ---- + ----- + 0
3 3 3 3 3
Rotation 2:
4pi pi pi 4pi 4pi pi
----- + ---- + 0 + ---- + ----- + 0 + ----- + ----
3 3 3 3 3 3
Rotation 3:
pi 4pi 4pi pi pi
0 + ---- + ----- + 0 + ----- + ---- + 0 + ----
3 3 3 3 3

Add all that up and you have 8 long arcs (4pi/3) and 8 short arcs (pi/
3).
4pi pi 32pi 8pi 40pi
8 * ----- + 8 * ---- = ------ + ----- = ------ inches
3 3 3 3 3

It is interesting to look at the pattern of numbers. Each time P moves
to or from a corner of the square, the arc is long. Each time it moves
to or from a midpoint of the edge of the square, the arc is short.