Can you build anywhere in Fallout 4?

Solution 1:

No, you can only build in the areas designated by the workshops you find in settlements. The entire area within the green is able to be built in, but once you leave that, you leave build mode.

Solution 2:

You can't build everywhere and you are not joining the settlements - you establish settlements mainly from zero or several settlers.
You are limited to build only inside green area at the place where workshop is located. Sometimes to use the workshop you need to clear all territory from enemies, sometimes you need to finish the quest to use the workshop so the settlers inside will permit you to do it.
If you do not like the limits of Fallout 4 for settlements locations you should search for suitable mods to unlock the other possibilities. For example, there is mode "Place everywhere". I do not use mods and it is not the promotion, mods just only the way to build at any place in F4.