The 2nd block defines VLAN 1 (with VID 1 by default) on port 3 and 5, with port 3 being untagged and port 5 being tagged.
The 3rd block, which is config 'switch_port' does nothing other than defining port 3 has the native VLAN of 1 (pvid = 1). That means all traffic belongs to VLAN1 will be forwarded to this port, and such traffic will be untagged. Same as above.
Why do we need to define VLAN function of that port twice?
I think the switch will considered all untagged traffic as VLAN3 traffic, which we can access on eth0.3 interface. All tagged frames with a VID=3 will be dropped.
If it also accepts tagged frames with VID=3 as you say, I feel confused because I can't tell which I shall get on eth0.3: VID=3 tagged frames or untagged frames?
Correct, but with the above configuration you can accept tagged frames in VLAN3, as well as untagged frames which will be assigned to VLAN3.
You can read more if you search for native vlan. Maybe it would be easier to understand like this:
This is a weird example, I haven't seen native vlan the same as the tagged vlans.
So the concept is that if a frame in VLAN 10 is to egress this port, it will be untagged.
I cannot imagine that the port would send the frame twice, one time tagged in VLAN3 and the other untagged.
I find it weird too, because the device which sends untagged frames will receive tagged frames in response -- it may have no clue about 802.1q. So, let's considered the native VLAN is different from the tagged VLANs on a single port. Are there any diffences between this (your example above):
Usually you use native vlan to blackhole untagged traffic or use it as a quick and dirty way to access the device in case of troubleshooting from a dot1q ignorant device (e.g windows).
In other cases I have seen this kind of configuration in some TP-link switches, when you want to change the ingress untagged frame vlan, because vlan1 cannot be disabled.
The difference of vlan and pvid in the above examples is that sometimes the devices do not support more than 16 or so vlans. So if you want to use a vlan above that limit, you specify the vlan id with pvid. The vlan number is then used for internal switch segregation, but not for tagging.