How can a country create an army in two weeks when faced by invasion?
They can't.
An army implies a great deal of organization, training, and support. There is no way you are going to pull one together in two weeks. You need tactical & strategic leadership, command & control structures, logistics corps, and people that understand and accept their place in the overall structure along with many other things to have an army. There is no way to put all of that together on the fly while an enemy is advancing across your territory.
Can a country without an army mobilize for an effective defense in two weeks?
Maybe.
This would hugely depend on the social/political structure of the country and populace, along with certain aspects of their economy and geography.
Guns
You mention limited private ownership of firearms. This is a huge damper on their likelihood of success. People who have never handled a gun tend to be afraid of them. They don't know how to carry, load, ready, aim, fire, handle recoil, clean, or otherwise maintain their weapons. They may have seen things in the movies, TV, or games, but there is a huge difference between what generally comes from the entertainment industry and reality. It is generally accepted (at least where I learned) that you need ~100 rounds through a firearm to get accustomed to how it handles. That does not mean proficiency, just that you are generally hitting in the vicinity of the target, can reload in a reasonable time frame, and are unlikely to hurt your self or panic/drop it when it goes off.
You mention 20,000 invaders. Just to match them in numbers you need to come up with 20,000 people, 20,000 firearms for them, and 2,000,000 rounds of practice ammunition, and time for them to do said practice before they are even close to being ready to handle a weapon without direct supervision. Not to mention the logistics of making sure the ammo matches the weapons for any given group. Even if you managed to pull it off, you are still at a huge disadvantage in this respect because your people just barely know how to use what they now have, your opponents will likely have fired thousands of rounds through their weapons, as well as having cross trained on the other weapons their forces use. A handgun handles very differently than a rifle or shotgun, and those handle differently than each other.
By contrast, a culture where the majority of the citizenship is familiar with and has ready access to firearms stands a much better chance. Particularly one in which marksmanship is prized and striven for. In such a place people will know how to handle their guns and what their strengths/limitations are. They will have their weapon of choice where they can get to it quickly and if they don't have ammunition readily available, they know what they need. They are likely to have practiced enough to hit targets reliably, and they will know how to care for their weapons. It is also likely that they have practiced with multiple types/styles of firearms at some level and could quickly be trained on a new weapon if their usual choice was unusable/unsuited for some reason. On average, they would be a decent match for the soldiers in terms of weapons handling and marksmanship.
Intelligence & Communication
The biggest part of war is not throwing bullets at each other, it is information, and making sure it reaches the right people at the right time.
- Where is the enemy?
- What do their forces consist of?
- What are their objectives, both short term and long term?
- Who do you have available to confront them?
- How are those people equipped?
- What is their level of experience?
- How can you pass orders to the people in the area?
- How will you get feedback and adjust when things inevitably change?
- Can you keep communication lines open when the enemy is trying to close them?
- Can you keep the enemy from listening in on your communications?
This is just a sampling of the types of information that needs to flow through a military organization for it to be effective. Your outlined scenario doesn't offer much in the way of hope on any of these points. Particularly with the last two, communications that are resistant to disruption and interception generally require some special equipment and arrangements to be in place before you can use them. It would be difficult to establish such after the invasion has started.
The biggest thing that would help is to have multiple redundant communications lines connecting your population centers. By this I mean no single points of failure in the network as a whole. Each town or city must be connected to several others, so that information can flow around any nodes the enemy takes offline. There needs to be a mix of mediums involved as well. Land lines and fiber can be cut, radios can be jammed, messengers can be intercepted. Doing all of these reliably at the same time is unlikely.
Command & Control
How are you going to pass instructions to your people and have them relay information back to you? You need the 200 militia in area X to form a blockade and delay the 1000 enemy soldiers that are coming down highway 1 for a day so you can get other people in position to stop them. Who are you going to contact to give those orders to? To the militia this looks like a suicide mission (and it might be), why should they follow those orders?
A large aspect of military training is to get people accustom to following orders and to recognize and accept their chain of command. By nature most people question what they are told, procrastinate, or otherwise avoid doing unpleasant things (like letting someone shoot at them). One of the primary objectives of basic training is to break down this natural inclination and get people to do what they are told, and do it right now! In combat there is often no time for question or explanation.
You need trust between the different layers of the organization. Front line troops need to react when given an order because delay means the situation has changed and what would have helped is now going to hurt or be pointless instead. They also need to trust that their commanders have information that they do not, and are not going to throw their lives away frivolously. Your lower and middle tier officers need to be able to read the situation and know when their orders no longer apply, when they have information that the upper ranks do not, when the situation allows for them to question what is coming from HQ, and when they need to act without waiting for orders. Your high command needs to trust that their field officers know what they are doing, and have quicker access to local information than HQ does. They need to judge what information needs to reach different areas and how to best use the troops available.
A few of the other answers imply that the civilian police forces can step in to provide this command structure. But that is not how they are organized or what they are trained to do. Generally speaking, police forces are local organizations with somewhat tenuous connections to higher authority. The police in a small town know their populace and area, they likely know how to reach the regional HQ/directors and their immediate neighbors, but they most likely do not take orders from them or communicate on a daily basis. Similar for large cities, precinct A has a specific area that they are focused on and don't pay much attention to what is happening in the other areas. In general, police training and procedure are designed to handle momentary situations on an individual or small group basis, not ongoing battles and confrontations involving hundreds to thousands of people.
Geography
The nature of the terrain will also play a large part in the success of the defense. By putting your defenders on a relatively small island you have already hampered them, they just don't have a lot of room to work with. However, if there are significant terrain features that can be leveraged as defensive points or barricades it will help a lot.
Dropping the bridges across major rivers will do a lot to slow the enemy. Mining them so that they can be blown mid crossing has the potential to do even better, but adds the risk that they will be able to disarm the charges or otherwise prevent you from detonating them, thereby securing a crossing.
Significant mountains implies passes that can be barricaded and defended, and opens the potential for things like triggered rock slides or avalanches to take out enemy columns or make the roads impassible.
Lots of heavy forest or swamps give places where your people can hide and launch harassing attacks while making it difficult for the enemy to maneuver.
Weather & climate are also a potential factor. The locals are accustom to it, they know which direction storms come from, how fast they move, and how severe they tend to be. They know what temperatures to expect, how they change through out the day, and how to live/work with them. If the invading force is not familiar with these things it is going to hamper them. If they are from significantly warmer/cooler climates they are also likely to encounter weather related injuries such as heat stroke or frostbite.
Economic
The nature of your countries economy will also play a part. Do they have significant natural resources and the infrastructure to turn them into finished products? Are such resources and infrastructure spread out enough to prevent the enemy from seizing them right off? Can the things that are produced and associated infrastructure be repurposed for war? Can such repurposing happen fast enough to make a difference?
As an example, if the country has a significant mining industry, that implies a fair amount of heavy equipment and raw materials to work with. There is also a decent chance that there is a ready supply of industrial explosives around. In the end, explosives are explosives, they can be used to build various types of mines, collapse bridges, destroy roads, and create various improvised weapons. Heavy equipment can be used to modify terrain, either in building defensive positions, or raising other obstructions. It is also conceivable that some could have armor bolted on and be used as APCs or other fighting vehicles.
Another key economic issue is whether the country is a net importer or exporter of various goods. How self sufficient are they? If the enemy just seized their primary port, how long are they going to be able to keep power on? run vehicles? feed their people?
Finally what is the lifestyle of the general populace and what are they accustom to? Societies which are accustom to lots of creature comforts and ready access to food, power, and other modern conveniences & luxuries are not going to fair as well when suddenly confronted with the hardships of war.
Modern America is a prime example, generally speaking, people are accustomed to being able to walk into any of a dozen stores on any day/time and being able to find what they need, be it a loaf of bread, clothing, a new car, or a high powered rifle. If something were to cause a disruption in the supplies or power flowing into a city, most of the people there would have no idea how to deal with it. More than a few days of disruption and society would start to collapse as supplies run out and people start to turn on each other.
Assuming Iceland is our model country, the enemy force has attacked from the western most point.
— but why? Moving troops via sea is way faster and cheaper, why not just went to the "Reykjavik" and take the capital with majority of population in it at once, and then spread out to other less populated areas. Britain in 1940 did exactly that. $\endgroup$