How does the EU decide how much to allocate for each country [of manufacture]?
Mostly by bilateral trade agreements.
how does the EU decide which particular companies are allowed to import
As an example, see UK customs notice 375
1.9 What does the HMRC CTQU do?
monitors and maintains details of the balances remaining of each TQ
inform the trade via updates to CHIEF when each TQ is at one of the following 3 stages:
Stage 1 Open - the quota fulfils the conditions set out in Article 308c of Regulation 2454/93, it is not expected to exhaust for some time therefore duty relief can be given automatically to any valid claim.
Stage 2 Critical - the TQ does not fulfil the conditions set out in Article 308c. The quota may be nearing exhaustion, be very small or have no operating history upon which to base a prediction of how quickly it will be used up.
Security for duty at the full non-quota rate of Customs Duty must be provided, as there is no guarantee that any claim will be allowed. New TQs will be critical from the start.
Stage 3 Quota exhausted - All claims will be rejected as no balance remains.
Is it first come, first serve?
Yes, mostly. A few are handled using import licences.