How does ground affect a circuit with a diode, connected to the power source which is connected to a ground and an LED for it to act like a NOT gate?
That circuit has several big design faults.

D2 short-circuits E3 to ground. A high current will flow which may destroy the battery, D2 or both.
Both ends of D3 are connected to ground. It will never light.
E1 is backwards.
When S4 is closed it will short-circuit E1 to ground. A very high current will flow but there will be no voltage available to power anything.

If you want the switch to turn off the LED when the switch is closed then try this:



simulate this circuit &ndash; Schematic created using CircuitLab
Figure 1. Closing SW1 causes the LED to switch off.

With SW1 open current flows through R1 and D1. D1 lights.
With SW1 closed current flows through R1 but D1 is short-circuited, there is 0 V across it and it turns off.

We wouldn't call this a NOT gate as it is not a true logic circuit.