When I open a COM port some pins on Arduino Uno goes low for about 2 seconds
What you see is expected: that's because opening the USB connection to the UNO will automatically trigger a reset of the ATmega chip of the board, hence your sketch will be executed from scratch, ie setup() will be called again then your loop() repeatedly.

Hence what you observe in detail:


open USB connection from PC
open USB connection on Arduino UNO
UNO USB chip (an ATmega16u2) triggers a RESET of the MCU (an ATmega328P-PU)
On reset, the MCU sets all pins to INPUT, i.e. high impedence, hence no voltage can be measured on any pin
Then the bootloader starts, performs some intialization and starts your sketch
Your sketch executes first setup(), so your pin is put in OUTPUT mode and set to HIGH: its voltage is thus measurable (5V)
your sketch loop() gets executed "forever" i.e.until a new reset or power supply disconnection