A systematic investigation of unstable steady-state solutions of the Darcy–Oberbeck–Boussinesq equations at large values of the Rayleigh number $\mathit{Ra}$ is performed to gain insight into two-dimensional porous medium convection in domains of varying aspect ratio $L$. The steady convective states are shown to transport less heat than the statistically steady ‘turbulent’ flow realised at the same parameter values: the Nusselt number $\mathit{Nu}\sim \mathit{Ra}$ for turbulent porous medium convection, while $\mathit{Nu}\sim \mathit{Ra}^{0.6}$ for the maximum heat-transporting steady solutions. A key finding is that the lateral scale of the heat-flux-maximising solutions shrinks roughly as $L\sim \mathit{Ra}^{-0.5}$, reminiscent of the decrease of the mean inter-plume spacing observed in turbulent porous medium convection as the thermal forcing is increased. A spatial Floquet analysis is performed to investigate the linear stability of the fully nonlinear steady convective states, extending a recent study by Hewitt et al. (J. Fluid Mech., vol. 737, 2013, pp. 205–231) by treating a base convective state, and secondary stability modes, that satisfy appropriate boundary conditions along plane parallel walls. As in that study, a bulk instability mode is found for sufficiently small-aspect-ratio base states. However, the growth rate of this bulk mode is shown to be significantly reduced by the presence of the walls. Beyond a certain critical $\mathit{Ra}$-dependent aspect ratio, the base state is most strongly unstable to a secondary mode that is localised near the heated and cooled walls. Direct numerical simulations, strategically initialised to investigate the fully nonlinear evolution of the most dangerous secondary instability modes, suggest that the (long time) mean inter-plume spacing in statistically steady porous medium convection results from a balance between the competing effects of these two types of instability.