Why did people draw so many continuous squares in the sand on the beach at Cape Juby?
They are not perfectly straight. Making them with modern GPS equipment should not be too difficult, you just keep a fixed distance to the previous line. They are only 5-6 meters wide.

Googling for cape juby tarfaya sand beach experiment I found this 16 Jan 2013 entry from the blog An overland adventure mentioning:
"Between the road and the sea is another experiment to save Tarfaya from being swallowed up by the Ergs (=sand dunes), mangrove. These trees have been introduced here from the tropics as one of the few salt loving, sand rooting toughs. They seem quite young from the window of the truck so I am guessing it is too early to tell if the project has been a success."

Maybe this is what you are seeing. I have contacted the blog writer to ask for confirmation. Update: The author confirmed that this is indeed what you're seeing: "Yes. Shame there is no picture."

Subsequent Googling for tarfaya mangrove turns up more info (often in French, where palétuvier is indeed mangrove), e.g. this Les mangoves du Sahara chapter from the Book Maroc 8 - Sud du Maroc et Sahara Occidental. This Lonely Planet E-Book PDF Marokko Reiseführer which is almost a literal translation, mentions a 900 meter long strip, but the artifact in the picture is approx 3.2 km.

The planting project was named The Manzanar project