Your sample code actually makes my point as a perfect example of "single player code" which is really malformed code that isn't targeting players correctly. Your code as-is will only work correctly if there is only one player on the server.
It could function properly in a multiplayer setting if the player targeting is corrected.
I hope this feedback will be taken constructively, because it can really improve your datapack making skills... and it took me quite a bit of time to write for you :D
To explain:
@p targets the player nearest to the positioning of the command being run.
You use @p every time without first determining a position from which to run the command... so the datapack mcfunction will default to running the command positioned at the world spawn point, which has nothing to do with your intent. You can end up selecting an irrelevant player if more than one player is present. This is a common target selector error which causes datapacks to malfunction in a multiplayer setting... unless you are actually trying to target the player closest to spawn, but from the description of your intent, you actually mean to target a player relative to an armor_stand position, not spawn.
As written your code will malfunction if:
1. Player furthest from spawn is the player within range of a beacon.
2. Player furthest from spawn is the player to place a beacon.
3. Player furthest from spawn is the player to mine a beacon.
Instead of executing every command positioned at spawn (irrelevant to your intent), better would be to position the execution of the command at the armor_stand around which the command intends to function... then any following @p will target the player closest to that armor_stand... which is your intent.
For example:
You wrote:
execute at @p if entity @e[tag=beacon,distance=..128] run gamerule doMobSpawning false
But you meant to do:
execute at @e[tag=beacon] run execute if entity @p[distance=..128] run gamerule doMobSpawning false
Another example:
You wrote:
execute at @p if score @p beaconPlaced matches 1.. run summon minecraft:armor_stand ~ 64 ~ {Tags:["beacon"],Invisible:1,Invulnerable:1,NoBasePlate:1,NoGravity:1}
First off... comparing a score to a fixed number doesn't require the use of "if score matches".
AND you don't care who is closest to spawn at all... you care who's beaconPlaced score is 1, no matter where they are.
You meant to do:
execute at @a[scores={beaconPlaced=1}] run summon minecraft:armor_stand ~ 64 ~ {Tags:["beacon"],Invisible:1,Invulnerable:1,NoBasePlate:1,NoGravity:1}
But EVEN IF you did want to target the player closest to spawn, it wouldn't be "execute at @p if score @p" it would be "execute at @p if score @s". Your target selectors are just all over the map... literally! The first @p searches and finds the player closest to spawn... who can thereafter be identified specifically as @s... why make the game look all over the entire map again to find the same guy twice by using @p a second time?
I hope you understand how improper player targeting is what's causing your datapacks to malfunction. No worries, mate. We all climbed this same learning curve. You're datapacks are getting better because YOU are learning and getting better.
Cheers and good luck!