Thanks to all the replies! Yesterday I managed to fix the problem. And YES the problem was the 9volt battery powering the motors. I changed that to better powersource and put capacitor to smooth the values and then everything worked 
And yes I have now different powersources for arduino and motors. Theres 9volt battery powering arduino and IC and AA-batteries for the motors.
code works perfectly but I refined it a little, but is still very simple and a work in process. It is meant to be very simple because I'll use it on some courses, but for my own amusement and interest I plan to work on it more...
if anyones interested, it's here
/* "RANDOM SWITCH CASE DRAWING ROBOT"
2010 Tomi Dufva
Uses l293ne IC-chip (H-bridge, for info look:http://www.ecs.umass.edu/ece/m5/tutorials/H-Bridge_tutorial.html
and http://luckylarry.co.uk/arduino-projects/control-a-dc-motor-with-arduino-and-l293d-chip/)
for driving 2 simple dc-motors on random directions. */
int moottori1a = 3; //pin 2 on l293
int moottori1b = 4; //pin 7 on l293:
int moottori2a = 5; //pin 10 on l293
int moottori2b =6; //pin 15 on l293:
int enablePin1 = 9; //pin 1 onl293
int enablePin2 = 9; //pin 9 on l293
int ledPin = 13; //LED which blinks when arduino resets, great visual to see if theres some short or other trouble
int ledPin2 = 12; // Led which blinks whenever Switch switches to new case
int liike = 0; //Variable for determining which way robot should go. ie. Which case it takes.
void setup(){
Serial.begin(9600); // debugging
pinMode(moottori1a, OUTPUT);
pinMode(moottori1b, OUTPUT);
pinMode(moottori2a, OUTPUT);
pinMode(moottori2b, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
digitalWrite(enablePin1, HIGH); // Putting IC on and motors running
digitalWrite(enablePin2, HIGH);// Putting IC on and motors running
// blink the LED 3 times. This should happen only once.
// if you see the LED blink three times, it means that the module
// reset itself,. probably because the motor caused a brownout
// or a short.
blink(ledPin, 7, 100);
}
void loop () {
int liike = random(1,7); // Assigns randomw value from 1-7 to liike variable
Serial.println(liike); // Prints assigned number to serial to see if it works
switch (liike) {
case 1: // Both motors forward
blink (ledPin2,2,100);
digitalWrite(moottori1a, LOW);
digitalWrite(moottori1b, HIGH);
analogWrite(enablePin1, 100);
digitalWrite(moottori2a, LOW);
digitalWrite(moottori2b, HIGH);
analogWrite(enablePin2, 100); // Assigning the speed of the motor
delay (1000);
break;
case 2: //Right motor forward left backward
blink (ledPin2,2,100);
digitalWrite(moottori1a, LOW);
digitalWrite(moottori1b, HIGH);
analogWrite(enablePin1, 100); // Assigning the speed of the motor
digitalWrite(moottori2a, HIGH);
digitalWrite(moottori2b, LOW);
analogWrite(enablePin2, 100); // Assigning the speed of the motor
delay (1000);
break;
case 3: //Right motor forward, left stop
blink (ledPin2,2,100);
digitalWrite(moottori1a, LOW);
digitalWrite(moottori1b, HIGH);
analogWrite(enablePin1, 100); // Assigning the speed of the motor
digitalWrite(moottori2a, LOW);
digitalWrite(moottori2b, LOW);
analogWrite(enablePin2, 100); // Assigning the speed of the motor
delay (1000);
break;
case 4: //Right motor backward, left forward
blink (ledPin2,2,100);
digitalWrite(moottori1a, HIGH);
digitalWrite(moottori1b, LOW);
analogWrite(enablePin1, 100); // Assigning the speed of the motor
digitalWrite(moottori2a, LOW);
digitalWrite(moottori2b, HIGH);
analogWrite(enablePin2, 100); // Assigning the speed of the motor
delay (1000);
break;
case 5: //Right motor backward, left stop
blink (ledPin2,2,100);
digitalWrite(moottori1a, HIGH);
digitalWrite(moottori1b, LOW);
analogWrite(enablePin1, 100); // Assigning the speed of the motor
digitalWrite(moottori2a, LOW);
digitalWrite(moottori2b, LOW);
analogWrite(enablePin2, 100);
delay (1000);
break;
case 6: //Right motor stop left forward
blink (ledPin2,2,100);
digitalWrite(moottori1a, LOW);
digitalWrite(moottori1b, LOW);
analogWrite(enablePin1, 100); // Assigning the speed of the motor
digitalWrite(moottori2a, LOW);
digitalWrite(moottori2b, HIGH);
analogWrite(enablePin2, 100); // Assigning the speed of the motor
delay (1000);
break;
case 7: //Right motor stop, left backward
blink (ledPin2,2,100);
digitalWrite(moottori1a, LOW);
digitalWrite(moottori1b, LOW);
analogWrite(enablePin1, 100); // Assigning the speed of the motor
digitalWrite(moottori2a, HIGH);
digitalWrite(moottori2b, LOW);
analogWrite(enablePin2, 100); // Assigning the speed of the motor
delay (1000);
break;
}
}
void blink(int whatPin, int howManyTimes, int milliSecs) {
int i = 0;
for ( i = 0; i < howManyTimes; i++) {
digitalWrite(whatPin, HIGH);
delay(milliSecs/2);
digitalWrite(whatPin, LOW);
delay(milliSecs/2);
}
}