FFT one-sided and Parseval theorem
Parseval's theorem says that the the following relationship holds
$$
\sum_{n=1}^{N} a[n]\,a^*[n] = \frac{1}{N}\sum_{k=1}^{N} A[k]\,A^*[k]
$$
where $A[k]$ is the discrete Fourier transform of $a[n]$, both assumed to be of length $N$ (no padding). This arises from the fact that the signal energy calculated from the time domain and frequency domain must be equal. See this answer for a little more detail about how this formula comes about.
If you want to calculate a one-sided spectrum, you need to throw away the negative frequencies (which are redundant when the signal is real). However, because half of the energy was contained in these entries, you need to multiply the energy in the remaining bins by 2 - except for the DC and Nyquist. I see that you have recognised correctly that the Nyquist is only present when $N$ is even, and that the first entry is the DC component regardless of $N$ - good. However, you have multipied the amplitudes by 2 (straight after the FFT), not the energy - the negative frequency bins contain half of the energy.
Instead, once you have calculated the discrete Fourier transform using the FFT algorithm (your variables $A$ and $B$), I would first then obtain the energy spectral density of the signal $a[n]$ using
$$
\textrm{ESD}_a[k] = |A[k]|^2 = A[k]\,A^*[k]
$$
and then throw away the negative frequencies from this vector instead. This way you throw away half of the energy correctly, and you can confidently multiply the energy in the remaining bins by $2$.
The following code illustrates this:
%% ODD
a = [1 2 3 4 5];
A = fft(a);
ESD_a = A.*conj(A);
ESD_a_onesided = [ESD_a(1) 2*ESD_a(2:3)]; 

E_a_timedomain = sum(a.^2)
E_a_twosided = sum(ESD_a)/5
E_a_onesided = sum(ESD_a_onesided)/5

%% EVEN
b = [1 2 3 4 5 6];
B = fft(b);
ESD_b = B.*conj(B);
ESD_b_onesided = [ESD_b(1) 2*ESD_b(2:3) ESD_b(4)]; 

E_b_timedomain = sum(b.^2)
E_b_twosided = sum(ESD_b)/6
E_b_onesided = sum(ESD_b_onesided)/6

The result is then correctly
E_a_timedomain = 55
E_a_twosided = 55
E_a_onesided = 55

E_b_timedomain = 91
E_b_twosided = 91
E_b_onesided = 91

EDIT----------------------------
Actually, the energy values of $55$ and $91$ obtained are only correct if we are assuming the sampling period of the signal acquisition was $T_s=1$.
The signal energy of a continuous signal $a(t)$ is defined as
$$
E_s = \int_{-\infty}^{+\infty}|a(t)|^2\;dt
$$
and the energy of a sampled version of it is then
$$
E_s = \sum_{n=1}^{N}|a[n]|^2\cdot T_s
$$
and you can see that we need to account for the signal sampling period to get the right energy.
The following verifies Parseval's theorem if we for example had collected the signal at some other sampling period $T_s\neq 1$
Ts = 0.05; % the sampling period of acquisition
Fs = 1/Ts; % the sampling frequency of the acquisition

%% ODD
a = [1 2 3 4 5];
N = 5

A = fft(a)*Ts;
ESD_a = A.*conj(A);
ESD_a_onesided = [ESD_a(1) 2*ESD_a(2:3)]; 

E_a_timedomain = sum(a.*conj(a))*Ts
E_a_twosided = sum(ESD_a)*Fs/N
E_a_onesided = sum(ESD_a_onesided)*Fs/N

%% EVEN
b = [1 2 3 4 5 6];
N = 6

B = fft(b)*Ts;
ESD_b = B.*conj(B);
ESD_b_onesided = [ESD_b(1) 2*ESD_b(2:3) ESD_b(4)]; 

E_b_timedomain = sum(b.^2)*Ts
E_b_twosided = sum(ESD_b)*Fs/N
E_b_onesided = sum(ESD_b_onesided)*Fs/N

with the output
E_a_timedomain = 2.75 [signal^2 sec]
E_a_twosided   = 2.75 [signal^2 sec]
E_a_onesided   = 2.75 [signal^2 sec]

E_b_timedomain = 4.55 [signal^2 sec]
E_b_twosided   = 4.55 [signal^2 sec]
E_b_onesided   = 4.55 [signal^2 sec]