Why do Uranus and Neptune have more methane than Jupiter and Saturn? So the standard theory of the solar nebula is that in the region of the gas planets, ice and rock could condense to form planetesimals, which could then accrete hydrogen and helium to form the gas giants. The giant planets are all mostly hydrogen and helium, but Uranus and Neptune have relatively large amounts of hydrogen compounds like methane (that's what gives them their color).
My question is: why did that happen? How did Uranus and Neptune get their methane? My impression is that all the gas giants were far enough out for methane to condense into ice, so how did Uranus and Neptune end up preferentially with methane?
Why does Uranus and Neptune have more methane than Jupiter and Saturn?


It's a combination of equations of state (EOS), serpentinization, and mixing (rotational and convective) that favors a preference for some reactions (and resulting compounds) over others.

See the references below.


  The giant planets are all mostly hydrogen and helium, but Uranus and Neptune have relatively large amounts of hydrogen compounds like methane (that's what gives them their color).


Jupiter and Saturn are gas giants, Uranus and Neptune are ice giants.




  My question is why did that happen? How did Uranus and Neptune get their methane? My impression is that all the gas giants were far enough out for methane to condense into ice, so how did Uranus and Neptune end up preferentially with methane?


See Wikipedia's "Extraterrestrial Atmosphere":



Graphs of escape velocity against surface temperature of some Solar System objects showing which gases are retained. The objects are drawn to scale, and their data points are at the black dots in the middle. Data is based on "Lecture 5: Overview of the Solar System, Matter in Thermodynamc Equilibrium" and "Stargazer's FAQ - How exactly are atmospheres held?".

Wikipedia says little about the atmosphere of these planets, and the least about Uranus and Neptune:


Atmosphere of Jupiter:


  "There are no methane clouds as the temperatures are too high for it to condense." - Source: "Jupiter's ammonia clouds — localized or ubiquitous?" (April 9 2004), by S.K.Atreya, A.S.Wong, K.H.Baines,  M.H.Wong, and T.C.Owen.
  
  Quotes from the paper:
  
  Page 502: "For the production of polycyclic aromatic hydrocarbons (PAHs), chemistry begins with the destruction of methane (CH$_4$) by solar UV photons at $\lambda \le$160 nm, ultimately leading to the formation of benzene ($c$-C$_6$H$_6$, or A$_1$) and other complex hydrocarbons (Fig. 3). In the polar auroral regions where energetic particles also break down methane, ion chemistry becomes dominant in the production of benzene and heavy hydrocarbons (Wong et al., 2003, and Fig. 3).".

Atmosphere of Saturn:


  "Ultraviolet radiation from the Sun causes methane photolysis in the upper atmosphere, leading to a series of hydrocarbon chemical reactions with the resulting products being carried downward by eddies and diffusion. This photochemical cycle is modulated by Saturn's annual seasonal cycle.". - Source: "Ethane, acetylene and propane distribution in Saturn's stratosphere from Cassini/CIRS limb observations" (Nov. 2008), by S. Guerlet, T. Fouchet, and B. Bézard.
  
  Quotes from the paper:
  
  Page 406: "3 Method
  
  We used a line-by-line radiative transfer model to calculate synthetic spectra. It included opacity from CH$_4$, CH$_3$D, C$_2$H$_6$, C$_2$H$_2$, C$_3$H$_8$, C$_3$H$_4, C$_4$H$_2 and collision-induced opacity from H2-He and H2-H2 . The atmospheric grid consisted in [of] 360 layers from 10 bar to 10−8 bar. It was coupled with an iterative inversion algorithm adapted from Conrath et al. (1998), in order to retrieve the atmospheric state (temperature, hydrocarbon vertical profiles) from the measured spectra.
  
  As a molecular emission intensity depends on both its abundance and temperature, we proceeded in two steps. First, we retrieved the temperature vertical profile from the methane ν4 emission band at 1305 m$^{−1}$ (assuming it is uniformly mixed with a vmr of 4.5 x10$^{−3}$ (Flasar et al. 2005)), providing information in the 1 mbar - 2 $\mu$bar region. 
  
  ...
  
  Figure 1 shows an example of a comparison between synthetic and observed emission bands of ethane, acetylene and propane at two given pressure levels (all the different pressure levels probed by CIRS have not
  been plotted for the sake of clarity) and Fig. 3 the Corresponding retrieved profiles.".



What that means is that more complex compounds than methane are favored by the conditions, see comments above concerning "equations of state".


Atmosphere of Uranus and Neptune:


  "The  gaseous outer layers of the ice giants have several similarities to those of the gas giants. These include long-lived, high-speed equatorial winds, polar vortices, large-scale circulation patterns, and complex chemical processes driven by ultraviolet radiation from above and mixing with the lower atmosphere.
  
  Studying the ice giants' atmospheric pattern also gives insights into atmospheric physics. Their compositions promote different chemical processes and they receive far less sunlight in their distant orbits than any other planets in the Solar System (increasing the relevance of internal heating on weather patterns).".



NASA Factsheets - Atmospheric composition (by volume, uncertainty in parentheses):


Jupiter


Major: Molecular hydrogen (H$_2$) - 89.8% (2.0%); Helium (He) - 10.2% (2.0%)
Minor (ppm): Methane (CH$_4$) - 3000 (1000); Ammonia (NH$_3$) - 260 (40); Hydrogen Deuteride (HD) - 28 (10); Ethane (C$_2$H$_6$) - 5.8 (1.5); Water (H$_2$O) - 4 (varies with pressure)
Aerosols: Ammonia ice, water ice, ammonia hydrosulfide

Saturn


Major: Molecular hydrogen (H$_2$) - 96.3% (2.4%); Helium (He) - 3.25% (2.4%) 
Minor (ppm): Methane (CH$_4$) - 4500 (2000); Ammonia (NH$_3$) - 125 (75); Hydrogen Deuteride (HD) - 110 (58); Ethane (C$_2$H$_6$) - 7 (1.5) 
Aerosols: Ammonia ice, water ice, ammonia hydrosulfide

Uranus


Major: Molecular hydrogen (H$_2$) - 82.5% (3.3%); Helium (He) - 15.2% (3.3%) Methane (CH$_4$) - 2.3% 
Minor (ppm): Hydrogen Deuteride (HD) - 148 
Aerosols: Ammonia ice, water ice, ammonia hydrosulfide, methane ice(?)

Neptune


Major: Molecular hydrogen (H$_2$) - 80.0% (3.2%); Helium (He) - 19.0% (3.2%); Methane (CH$_4$) 1.5% (0.5%)
Minor (ppm): Hydrogen Deuteride (HD) - 192; Ethane (C$_2$H$_6$) - 1.5
Aerosols: Ammonia ice, water ice, ammonia hydrosulfide, methane ice(?)



Additional references:

"Methane in the Solar System" in English, (Bol. Soc. Geol. Mex [online]. 2015, vol.67, n.3, pp.377-385.), by Andrés Guzmán-Marmolejo and Antígona Segura.

"Abiotic Production of Methane in Terrestrial Planets" (Astrobiology. 2013 Jun; 13(6): 550–559), by Andrés Guzmán-Marmolejo, Antígona Segura, and Elva Escobar-Briones.

"Methane clathrates in the solar system" (Astrobiology. 2015 Apr;15(4):308-26), by Mousis O, Chassefière E, Holm NG, Bouquet A, Waite JH, et al.

NASA - "Scientists Model a Cornucopia of Earth-sized Planets" (Sept. 24 2007).