Autocorrelation of a uniform random process
As suggested I am adding my comments as an answer.
The sample autocorrelation function (ACF) for $n$ observations is given by

$\hat{p}_x(m) = \frac{\sum_{n=0}^{N-m-1}(x_n - \bar{x})(x_{n+m} - \bar{x})}{\sum_{n=0}^{N-m-1}(x_n - \bar{x})^2} $

To understand why you have a difference between figure 1 and figure 2, lets assume we are looking at observations $x_n$ being zero mean. Let be $y_n = x_n +c$ with c being a constant. Looking now at matlabs help for xcorr for the input $y_n$ we get

$r(m)=\sum_{n=0}^{N-m-1}y_n y_{n+m}^* = \sum_{n=0}^{N-m-1}(x_n + c)(x_{n+m} + c)$

which can be summarized to

$\sum_{n=0}^{N-m-1}(x_nx_{n+m}) + (N-m)c^2$

In the case of xcorr $m$ equals $m=-N,...,N$. Which means you are adding a triangle to your result.

To calculate the ACF matlab has the autocorr function, which takes care of normalization and demeaning of the input.