Typical way to do a switch on arduino is this:
Attach 1 terminal of switch to digital pin (anything)
Attach 2nd terminal of switch to ground.
IN your code do this:
you must add the pinMode(pin,INPUT), don’t forget that!
But what happens is this sequence enabled the “internal pullup resistor.” So the circuit looks like this:
PIN-(inside the chip)—>20,000 Ohm resistor (inside the chip) —> switch! —> gnd.
When digitalRead(pin)==LOW, the switch is closed.
when digitalRead(pin)==HIGH, the switch is open.
This is the typical way to do this.
If you use the 3.3V pin, you must add a resistor. So it must go 3.3V, SWITCH, RESISTOR, GROUND. Then, the resistor prevents you from shorting the 3.3V to ground.
The one benefit of doing your way, to an analog pin, is that you can use one pin for multiple switches. If you set up your resistors correctly there can be a voltage divider and a certain voltage corresponds to a different switch having been pressed. it’s trickier, though.
Edit: more detail. The issue with your method is that you just have 3.3V - SWITCH - Pin. When switch is open, voltage is “floating” and you cannot know for certain that is counts as LOW. Eventually it will be LOW when you run analogRead, but that is just because analogRead takes a miniscule current from the capacitance of the wire. You also are adding 3.3V direct to the pin, so if you do something like pinMode(A0, OUTPUT), then digitalWrite(pin,LOW) you will damage the pin by flooding with 3.3V and no current limiting resistor. This is a bit too much detail, though.
Also, try googling “arduino basic switch tutorial” or something like that, I’m sure there will be good tutorials. I personally really enjoyed the “arduino cookbook” when I first was starting out. it starts with the very basics and gets to some serious details, too, over time in the book.