The ions in a solid ionic compound are not randomly arranged. Instead, they have a regular, repeating arrangement called an ionic lattice. The lattice is formed because the ions attract each other and form a regular pattern with oppositely charged ions next to each other.
The lattice arrangement continues in three dimensions. This is why solid ionic compounds can form crystals with regular shapes. A crystal contains very many ions, so the ionic lattice is a ‘giant’ ionic lattice.
The ionic lattice is held together by ionic bonds. In three-dimensional models, ionic bonds are shown as straight lines between ions. This is only to keep things simple, because ionic bonds can act in any direction.