You can align the bars of a bar graph by their left of right edge (pass a negative width to align using the right edge) - in this way you can get side-by-side bars. Alternatively you can stack the bars.
Here is the code with the output:
import matplotlib.pyplot as plt
A = {2018: 23, 2019:30}
B = {2018: 26, 2019:35}
fig, (ax1, ax2) = plt.subplots(1,2, figsize=(12,5))
ax1.bar(A.keys(), A.values(), width=0.2, align='edge', label='A')
ax1.bar(B.keys(), B.values(), width=-0.2, align='edge', label='B')
ax1.set_xticks([2018, 2019])
ax1.set_xlabel('YEAR')
ax1.legend()
ax2.bar(A.keys(), A.values(), width=0.4, align='center', label='A')
ax2.bar(B.keys(), B.values(), bottom=[A[i] for i in B.keys()], width=0.4, align='center', label='B')
ax2.set_xticks([2018, 2019])
ax2.set_xlabel('YEAR')
ax2.legend()
fig.show()

EDIT: If you start to deal with more data it makes sense to use a package that can handle data more easily. Pandas is a great package that will do this for you.
Here is an example with 4 sets of time-series data:
import matplotlib.pyplot as plt
import pandas as pd
A = {2018: 23, 2019:30}
B = {2018: 26, 2019:35}
C = {2018: 30, 2019:40}
D = {2018: 20, 2019:50}
df = pd.DataFrame([A,B,C,D], index=['A','B','C','D']).transpose()
fig, ax= plt.subplots(1,1, figsize=(6,5))
df.plot.bar(ax=ax)
ax.set_xlabel('YEAR')
fig.tight_layout()
fig.show()
The output is this figure:
