Combat begins when an attack is declared or the GM has the party roll initive. The pcs and npcs take turns according to inititive order, and have s set number of actions they can take per turn. Each round is considered ten seconds of combat.
It's not easy to react to what you didn't know was coming. Sometimes, you fall into an ambush, or you trigger a trap that alerts the entire compound to your location, allowing them to attack while you're still processing the mistake you've made. In cases like this, the GM may employ a surprise round.
At the beginning of combat, the GM can determine whether or not any particular creature is considered "Surprised". Any creature that doesn't start a round with surprise is able to participate in the first round as normal, while surprised creatures are skipped over in initiative order until the next round. For example, say the party's dealer is sitting at a poker table in a casino with the big boss who they discover is cheating. Cheating at cards is the dealer's thing, and he's set to use the cards as throwing knives, so he declares an attack on the big boss using his cards. The big boss, his men, and any of the players who weren't prepared for the trickster to do trickster things would be considered surprised. The Trickster, who started the combat, would be considered first in initiative order for that round. All players roll initiative (d% + dex save) and the GM rolls for the Big Boss, his posted guards, and any other relevant NPCs. The GM is in charge of keeping track of initiative order, so they might want to write down the order. Any surprised PC's or NPC's get skipped over for the first round, as the Hunter, who had mentioned to the GM as soon as she saw the Dealer sit at the table that she wanted to ready her Beast Within skill, showing she was probably prepared for and watching for a fight, takes the next spot in initiative. All unsurprised characters take their turns, then combat starts as normal, with regular initiative order.
Let's do another scenario. The party is traveling through the forest when they see a downed tree on the road ahead. As the party's defender gets out to check it, their player asks the GM if they can ready a dodge reaction. The GM okays it, then describes the scene as arrows come cascading down from the trees. The Defender gets his reaction, but wasn't prepared for an ambush of this size, nor were the rest of the party, still in the wagon, who didn't ready reactions. The goblin archers hidden amongst the trees roll to maintain their stealth after letting their arrows loose, then normal initiative is rolled. In this case, the surprise round was the goblins', and they took the surprise round before the GM asked to roll initiative, so that he could maintain the element of surprise. If all players are considered surprised, the GM is under no obligation to announce that combat is beginning with a surprise round. They can simply describe actions and the results, just as if it were any other action, though the party may get suspicious seeing the GM rolling dice.
Not every combat will have a surprise round. In fact, most won't, in my experience, though that depends on the setting, tone, and party composition. If you have an assassin on your team, for example, they're likely to be much more common.
At the beginning of combat, all participating players and npcs must roll initiative. These rolls determine the order in which the rounds in combat are dealt, for example, if the Cursecaster goes before the lesser wyvern. Initiative is calculated as d% + Dexterity save, and the highest number goes first. If there's a tie in initiative between players and NPCs, players are prioritized. If there's a tie in initiative between two players, then both players roll again, and the higher number goes first between the tied players.
Let's say that it's your turn in combat. You have four different actions you can take: your primary action, secondary action, movement action, and reaction. A primary action is able to do more than a secondary action, which can do more than a reaction, though reactions can be used any time, including outside of your round to react to an action that someone else takes. Movement actions are fairly self-explanatory. You can take these actions in any order you choose.
During the primary action, you're able to take one of the following actions or anything else your GM may determine would take a primary action.
Attack
Prepare a reaction
Move up to speed
Enter or maintain stealth
Use an item
Use a skill, feat, or ability that requires a main action or less
Cast a spell that requires a main action or less
use an assist action
Grapple
During the secondary action, you're able to take one of the following actions or anything else your GM may determine would take a secondary action.
Prepare a reaction
Move up to speed
Enter or maintain stealth
Use a skill, feat, or ability that requires a secondary action or less
Cast a spell that costs a secondary action or less
Move up to speed (must be used before any other abilty/spell that has movment effect)
Dodge
Block
Maintain stealth
Use a skill, feat, or ability that requires a reaction
Cast a spell that requires a reaction
Attack of opportunity
Drinking a full bottle (Primary and Secondary Actions)